我正在用需要连接到 Adwords 的 codeigniter 用 php 开发一个应用程序,我有很多问题......
首先,我有一个测试帐户,我不知道我是否连接正确,因为我不知道我必须将什么作为 developerToken、clientId 和 defaultServer。哪个是正确的?
$username = "[email protected]";
$password = "my_password";
//Developer Token options
$developerToken_1 = "E2SGs1l7gEWWdCfeYSO4oA"; //It's not my real token..
$developerToken_2 = "[email protected]++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('[email protected]');
//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/