我正在使用 codeigniter 在 php 中开发一个需要连接到 Adwords 的应用程序,我有很多问题...
首先,我有一个测试帐户,但我不知道我是否连接正确,因为我不知道我必须输入什么作为 developerToken、clientId 和 defaultServer。哪个是正确的?
$username = "my_email@gmail.com";
$password = "my_password";
//Developer Token options
$developerToken_1 = "E2SGs1l7gEWWdCfeYSO4oA"; //It's not my real token..
$developerToken_2 = "my_email@gmail.com++USD";
$user = new AdWordsUser(null, $username, $password, $developerToken);
//Default Servers
//Option 1
$user->SetDefaultServer("https://adwords.google.com/");
//Option 2
$user->SetDefaultServer("https://adwords-sandbox.google.com");
//Option 3
$user->SetDefaultServer("https://sandbox.google.com");
//Client ID
//Option 1
$user->SetClientId('client_id_1+my_email@gmail.com');
//Option 2
$user->SetClientId('1234567890');
我认为我必须使用 adwords 版本 v201306
$campaignService = $user->GetService('CampaignService', 'v201306');
如果我使用“https://adwords.google.com/”作为服务器,我会收到:
Uncaught exception 'OAuth2Exception' with message '{
"error" : "invalid_client"
}'
对于其他服务器,我收到:
A PHP Error was encountered
Severity: Warning
Message:
SoapClient::SoapClient(https://sandbox.google.com/api/adwords/cm/v201306/CampaignService?wsdl): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
Filename: Lib/AdsSoapClient.php
或
A PHP Error was encountered
Severity: Warning
Message:
SoapClient::SoapClient(https://adwords-sandbox.google.com/api/adwords/cm/v201306/CampaignService?wsdl): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
Filename: Lib/AdsSoapClient.php
我该怎么办?看了太多的网页,不知道怎么解决
非常感谢!!
最佳答案
首先,您可以在此处找到有关将 Analytics API 用作测试帐户的信息(包括服务端点 URL):https://developers.google.com/adwords/api/docs/test-accounts
其次,自述文件指出使用以下方法设置您的服务:
$campaignService = $user->getCampaignService('v201306', 'https://adwords.google.com');
最后,您用来初始化 AdWordsUser 对象的参数似乎有点偏离,自述文件还说明了以下内容:
$user = new AdWordsUser(NULL, NULL, NULL, $developerToken,
$applicationToken, $userAgent, $clientCustomerId, NULL, NULL,
$oauth2Info);
关于php - 在没有 auth.ini 的情况下在 PHP (Codeigniter) 中登录 Api AdWords,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17770891/