【发布时间】:2022-07-13 22:54:23
【问题描述】:
我正在使用 google-ads-api。我的目标是获得特定广告系列的展示次数和点击次数。 这些是我做过的事情。
- 创建了谷歌服务帐号
- 从 github 下载 google-ads-library
- 在我的 adsapi.ini 文件中添加了 clientid、secretid、刷新令牌。
当我运行代码时,它给了我错误。
Google\ApiCore\ApiException { "message": "调用者没有权限", "code": 7, "status": "PERMISSION_DENIED", "details": [ { "@type": "type.googleapis.com/google.ads. googleads.v9.errors.GoogleAdsFailure", "errors": [ { "errorCode": { "authorizationError": "USER_PERMISSION_DENIED" }, "message": "用户无权访问客户。注意:如果您是访问客户客户时,必须在“login-customer-id”标头中设置经理的客户 ID。请参阅 https://developers.google.com/google-ads/api/docs/concepts/call-structure#cid" } ], "requestId": "pKHgfIr99F5XApaPFBnrLQ" } ] }
我的 adsapi.ini
[GOOGLE_ADS]
; Required Google Ads properties.
name = "Google Ads"
developerToken = "*****-*******_*"
; Optional. Set a friendly application name identifier.
userAgent = "Scraper"
; Optional additional AdWords API settings.
; endpoint = "https://adwords.google.com/"
; isPartialFailure = false
; Optional setting for utility usage tracking in the user agent in requests.
; Defaults to true.
; includeUtilitiesInUserAgent = true
[ADWORDS_REPORTING]
; Optional reporting settings.
; isSkipReportHeader = false
; isSkipColumnHeader = false
; isSkipReportSummary = false
; isUseRawEnumValues = false
[OAUTH2]
; Required OAuth2 credentials. Uncomment and fill in the values for the
; appropriate flow based on your use case. See the README for guidance:
; https://github.com/googleads/googleads-php-lib/blob/master/README.md#getting-started
; For installed application or web application flow.
clientId = "**********************"
clientSecret = "********************"
refreshToken = "***********************"
For service account flow.
; jsonKeyFilePath = "INSERT_ABSOLUTE_PATH_TO_OAUTH2_JSON_KEY_FILE_HERE"
; scopes = "https://www.googleapis.com/auth/adwords"
; impersonatedEmail = "INSERT_EMAIL_OF_ACCOUNT_TO_IMPERSONATE_HERE"
[SOAP]
; Optional SOAP settings. See SoapSettingsBuilder.php for more information.
; compressionLevel = <COMPRESSION_LEVEL>
; wsdlCache = <WSDL_CACHE>
[PROXY]
; Optional proxy settings to be used by SOAP requests.
; host = "<HOST>"
; port = <PORT>
; user = "<USER>"
; password = "<PASSWORD>"
[LOGGING]
; Optional logging settings.
; soapLogFilePath = "/soap.log"
; soapLogLevel = "INFO"
; reportDownloaderLogFilePath = "path/to/your/report-downloader.log"
; reportDownloaderLogLevel = "INFO"
; batchJobsUtilLogFilePath = "path/to/your/bjutil.log"
; batchJobsUtilLogLevel = "INFO"
【问题讨论】:
-
您正在发送 login-customer-id 标头? developers.google.com/google-ads/api/docs/migration/…
-
我也有同样的问题。你解决了吗?
-
是的,我记得我把 google_ads_php.ini 文件放到了我的根 C 盘。
标签: google-ads-api google-api-client