# Platform API Scripts — คู่มือการติดตั้ง scripts/ เหล่านี้เป็น bridge สำหรับเชื่อมต่อกับ platform APIs ณ ตอนนี้เป็น **placeholder** — ต้องติดตั้ง dependencies ก่อนใช้งาน ## Prerequisites (ทั่วไป) ```bash # Hermes ต้องมี tools เหล่านี้ # web_search สำหรับค้นหาข้อมูล # terminal สำหรับรัน scripts ``` ## Google Ads API ### Dependencies ```bash pip install google-ads ``` ### Authentication 1. ไปที่ https://console.cloud.google.com/ → สร้าง Project 2. Enable Google Ads API 3. สร้าง OAuth 2.0 credentials → ดาวน์โหลด JSON 4. ไปที่ https://ads.google.com/ → Tools → API Center - ขอ Developer Token (ต้องผ่าน basic approval) 5. ตั้งค่า environment: ```bash export GOOGLE_ADS_DEVELOPER_TOKEN="your-token" export GOOGLE_ADS_CLIENT_ID="your-client-id" export GOOGLE_ADS_CLIENT_SECRET="your-client-secret" export GOOGLE_ADS_REFRESH_TOKEN="your-refresh-token" export GOOGLE_ADS_LOGIN_CUSTOMER_ID="manager-account-id" ``` ### ทางเลือก: Google Ads MCP Server https://github.com/googleads/google-ads-mcp ใช้กับ Hermes/Claude โดยตรง ไม่ต้องเขียน script แยก ## Meta Ads API ### Dependencies ```bash pip install facebook-business ``` ### Authentication 1. ไปที่ https://developers.facebook.com/ → สร้าง App 2. เพิ่ม Marketing API product 3. ต้องผ่าน business verification (ใช้บัตรประชาชน/เอกบริษัท) 4. Generate access token: - permissions: `ads_read`, `ads_management`, `business_management` 5. ตั้งค่า environment: ```bash export META_ACCESS_TOKEN="your-token" export META_AD_ACCOUNT_ID="act_xxxxxxxx" export META_APP_ID="your-app-id" export META_APP_SECRET="your-app-secret" ``` ## Google Search Console API ### Dependencies ```bash pip install google-auth google-auth-oauthlib google-auth-httplib2 ``` ### Authentication ใช้ gcloud application-default credentials: ```bash gcloud auth application-default login \ --scopes=https://www.googleapis.com/auth/webmasters.readonly ``` ### หมายสำคัญ - **seo-analysis skill** มี scripts GSC ครบถ้วนที่ `~/.hermes/skills/seo-analysis/scripts/` - สามารถ adapt มาใช้กับ multi-client ได้ - แต่ละ client ต้องเพิ่ม service account email ใน GSC property → Settings → Users ## แนวทางการสร้าง scripts จริง เมื่อพร้อม implement scripts จริง: 1. **Copy pattern** จาก seo-analysis skill scripts — มีโครงสร้างครบ (analyze_gsc.py, url_inspection.py, ฯลฯ) 2. **แยก config** ต่อ client — ใช้ .env หรือ config.json ต่อ client 3. **Output format** — JSON ที่ orchestrator อ่านได้ (state.json friendly) 4. **Error handling** — ถ้า token หมดอายุ หรือ API quota หมด ให้แจ้ง orchestrator