廣告來源

您可以使用 AdMob API,以程式輔助方式查看中介服務廣告來源。詳情請參閱 accounts.adSources.list

使用 Curl 提出要求

  1. 載入Secrets 檔案,然後產生授權憑證。

    首次執行這個步驟時,系統會要求您在瀏覽器中接受授權提示。接受邀請前,請先確認您登入的 Google 帳戶有權存取 AdMob API。應用程式將有權代表目前登入的帳戶存取資料。

    如要進行驗證和授權,建議使用 oauth2l,這是用於處理 Google OAuth 2.0 的簡單指令列工具。安裝 oauth2l 並執行下列指令,然後將 path_to_credentials_json 替換為您註冊雲端應用程式時下載的 credentials.json 檔案路徑。首次執行時,指令會引導您完成 OAuth 2.0 授權流程。後續執行作業會自動重新整理權杖。

    oauth2l header --json path_to_credentials_json --scope admob.readonly
    
  2. 列出廣告來源。

    pub-XXXXXXXXXXXXXXXX 替換為發布商 ID,即可取得 AdMob 廣告來源資訊。請參閱操作說明,瞭解如何查看發布商 ID。

    curl --http1.0 -X GET https://admob.googleapis.com/v1beta/accounts/pub-XXXXXXXXXXXXXXXX/adSources \
     -H "$(oauth2l header --json path_to_credentials_json --scope admob.readonly)"
    

    回應範例:

    {
     "adSources": [
       {
         "name": "accounts/pub-XXXXXXXXXXXXXXXX/adSources/5450213213286189855",
         "adSourceId": "5450213213286189855",
         "title": "AdMob Network",
       }
     ]
    }