4

我正在使用需要连接到 Adwords 的 codeigniter 用 php 开发一个应用程序,我有很多问题......

首先,我有一个测试帐户,我不知道我是否连接正确,因为我不知道我必须把什么作为 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

我应该怎么办?我在太多的网站上阅读了很多,我不知道如何解决它

非常感谢!!

4

1 回答 1

0

首先,您可以在此处找到有关使用 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);
于 2013-09-24T13:16:39.013 回答