close
  • 新增一個管理帳戶:此帳戶不能已經是 AdWords 的帳戶,所以必須先取得新的gmail帳號再註冊為管理帳戶
  • 取得 Developer Token
    • 以管理帳戶登入AdWords
    • 點右上角齒輪,於下拉選單裡選 帳戶設定,左方功能表會出現 AdWords API 中心,填寫所有訊息
    • 開發人員權杖(DeveloperToken)的值記下來,開發 AdWords API 時要提供 DeveloperToken 的值
  • 新增一個測試帳戶:此帳戶不能已經是 AdWords 的帳戶或是 AdWords 管理帳戶,亦即必須再新增一個gmail帳號後再註冊為測試管理帳戶
  • 建立一個 OAuth 登入
    • 測試帳戶身份登入 Google Developers Console
    • 新增一個專案
    • 於左方功能表點 憑證
    • 點 建立憑證,於下拉選單裡選 OAuth 用戶端 ID
    • 完成必要的設定:
      在 已授權的 JavaScript 來源 輸入 http://localhost
      在 已授權的重新導向 輸入 http://localhost:8080/
    • 用戶端 ID(client identifier)、用戶端密碼(client secret)的值記下來,開發 AdWords API 時要提供
  • 取得開發 AdWords API 的函數庫(client library)
  • 產生一個 refresh token,開發 AdWords API 時要提供
    • 先準備好 redirect_uri 程式,在 http://localhost:8080/index.asp 裡的程式碼:
      <form id="oau" method="post" action="https://www.googleapis.com/oauth2/v4/token">
        <input type="hidden" name="code" value="<%=Request("code") %>" />
        <input type="hidden" name="client_id" value="測試帳戶身份的 oAuth 用戶端 ID" />
        <input type="hidden" name="client_secret" value="測試帳戶身份的 oAuth 用戶端密碼" />
        <input type="hidden" name="redirect_uri" value="http://localhost:8080/" />
        <input type="hidden" name="grant_type" value="authorization_code" />
      </form>
      <script type="text/javascript">
        $(function () {
          $('#oau').submit();
        });
      </script>
      
      
    • 透過以下網址,會取得 Access Token 後再由 http://localhost:8080/index.asp 取得 refresh token
      https://accounts.google.com/o/oauth2/v2/auth?scope=https://adwords.google.com/api/adwords&state=/profile&redirect_uri=http://localhost:8080/&response_type=code&client_id=75194289957-iffle279kkkpikfbpvgj71kj2682j870.apps.googleusercontent.com&access_type=offline&approval_prompt=force
      
      client_id: 測試帳戶身份的 oAuth 用戶端 ID
      scope: https://adwords.google.com/api/adwords
      redirect_uri: http://localhost:8080/ ,這必須與 oAuth 憑證設定裡的 已授權的重新導向 一樣。只能是 http://localhost:port ,用其他的路徑是不可以的
      response_type: code
      access_type: offline
      approval_prompt: force
  • 測試帳戶身份登入 AdWords,於右方點 + 帳戶,於下拉選單選 新建 AdWords 帳戶,有 AdWords 帳戶才能建立 廣告活動(campaign)
arrow
arrow
    文章標籤
    AdWords API
    全站熱搜

    alueiphon 發表在 痞客邦 留言(0) 人氣()