Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google Adword PHP客户端库无法';无法连接到主机_Php_Google Ads Api_Client Library - Fatal编程技术网

Google Adword PHP客户端库无法';无法连接到主机

Google Adword PHP客户端库无法';无法连接到主机,php,google-ads-api,client-library,Php,Google Ads Api,Client Library,我正在连接我的网站,以连接到谷歌广告词,创建广告和营地取决于我的网站上的产品。我尝试通过发送直接curl请求并解析收到的SOAP响应来连接。但这对于每个请求来说都变得太复杂了。因此,我尝试使用Google代码中提供的PHP客户端库。但没有一个例子是正确的。我在auth.ini文件中更改了用户帐户的详细信息,但仍在执行它所说的示例文件 获取authToken失败。原因: 无法连接到主机 我尝试在不同的服务器上运行脚本,但仍然得到相同的错误 下面是从GoogleAdWords获取所有广告的代码,这是

我正在连接我的网站,以连接到谷歌广告词,创建广告和营地取决于我的网站上的产品。我尝试通过发送直接curl请求并解析收到的SOAP响应来连接。但这对于每个请求来说都变得太复杂了。因此,我尝试使用Google代码中提供的PHP客户端库。但没有一个例子是正确的。我在auth.ini文件中更改了用户帐户的详细信息,但仍在执行它所说的示例文件

获取authToken失败。原因: 无法连接到主机

我尝试在不同的服务器上运行脚本,但仍然得到相同的错误

下面是从GoogleAdWords获取所有广告的代码,这是一个来自客户端库的示例文件

$path = dirname(__FILE__) . '/../../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);

require_once 'Google/Api/Ads/AdWords/Lib/AdWordsUser.php';

try {
  // Get AdWordsUser from credentials in "../auth.ini"
  // relative to the AdWordsUser.php file's directory.
  $user = new AdWordsUser();

  // Log SOAP XML request and response.
  $user->LogDefaults();

  // Get the AdGroupAdService.
  $adGroupAdService = $user->GetAdGroupAdService();

  $adGroupId = (float) '01';

  // Create selector.
  $selector = new Selector();
  $selector->fields = array('Id', 'AdGroupId', 'Status');
  $selector->ordering = array(new OrderBy('Id', 'ASCENDING'));

  // Create predicates.
  $adGroupIdPredicate = new Predicate('AdGroupId', 'IN', array($adGroupId));
  // By default disabled ads aren't returned by the selector. To return them
  // include the DISABLED status in a predicate.
  $statusPredicate =
      new Predicate('Status', 'IN', array('ENABLED', 'PAUSED', 'DISABLED'));
  $selector->predicates = array($adGroupIdPredicate, $statusPredicate);

  // Get all ads.
  $page = $adGroupAdService->get($selector);

  // Display ads.
  if (isset($page->entries)) {
    foreach ($page->entries as $adGroupAd) {
      printf("Ad with id '%s', type '%s', and status '%s' was found.\n",
          $adGroupAd->ad->id, $adGroupAd->ad->AdType, $adGroupAd->status);
    }
  } else {
    print "No ads were found.\n";
  }
} catch (Exception $e) {
    echo 'Inside catch exception';
  print $e->getMessage();
}
在settings.ini文件中

默认\u服务器= "https://adwords-sandbox.google.com"

;AUTH_SERVER=”“

在auth.ini文件中 我的Google帐户的用户名和密码设置正确

有人能帮我解决这个问题吗


谢谢

这是
AUTH_SERVER
设置,而不是
DEFAULT_SERVER
,它指示了身份验证请求的发送位置。这应该在
settings.ini的底部,但通常会被注释掉,因此
https://www.google.com使用了
。您应该检查
AUTH_SERVER
是否已被注释掉,是否可以连接到
https://www.google.com

请显示您正在使用的一些代码。您正在尝试连接到哪个主机?是否可访问?是,验证服务器设置被注释掉,并指向默认服务器