SOAP>未捕获的SoapFault异常:[HTTP] SoapClient-> __ doRequest

时间:2017-12-15 09:06:19

标签: php soap google-dfp

有人说明为什么我会收到此错误?我猜测它是因为WSDL中的某些路径无法解决?

致命错误:未捕获的SoapFault异常:[HTTP]无法连接到/usr/local/ampps/www/dfpapi/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php:90堆栈中的主机跟踪:#0 /usr/local/ampps/www/dfpapi/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php(90):SoapClient-> __ doRequest(' https:// ads.goo ...','',1,0)#1 [内部功能]:Google \ AdsApi \ Common \ AdsSoapClient-> __ doRequest(' https:/ /ads.goo...' ;,'',1,0)#2 / usr / local / ampps / www / dfpapi / googleads-php-lib / src / Google / AdsApi / Common / AdsSoapClient.php(131):SoapClient-> __ soapCall(' getCurrentNetwo ...',Array,NULL,Array,Array)#3 / usr / local / ampps / www / dfpapi / googleads -php-lib / src / Google / AdsApi / Dfp / v201711 / NetworkService.php(98):Google \ AdsApi \ Common \ AdsSoapClient-> __ soapCall(' getCurrentNetwo ...',Array)# 4 /usr/local/ampps/www/dfpapi/googleads-php-lib/getdfpdata.php(36):Google \ AdsApi \ Dfp \ v201711 \ NetworkService-> getCurrentNetwork()#5 / usr / local /ampps/www/dfpapi/googleads-php-lib/getdfpdata.php(96):在/usr/local/ampps/www/dfpapi/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php中运行在第90行

我的代码是

require 'vendor/autoload.php';
use Google\AdsApi\Common\OAuth2TokenBuilder;
use Google\AdsApi\Dfp\DfpServices;
use Google\AdsApi\Dfp\DfpSession;
use Google\AdsApi\Dfp\DfpSessionBuilder;
use Google\AdsApi\Dfp\Util\v201711\ReportDownloader;
use Google\AdsApi\Dfp\Util\v201711\StatementBuilder;
use Google\AdsApi\Dfp\v201711\Column;
use Google\AdsApi\Dfp\v201711\DateRangeType;
use Google\AdsApi\Dfp\v201711\Dimension;
use Google\AdsApi\Dfp\v201711\ExportFormat;
use Google\AdsApi\Dfp\v201711\NetworkService;
use Google\AdsApi\Dfp\v201711\ReportJob;
use Google\AdsApi\Dfp\v201711\ReportQuery;
use Google\AdsApi\Dfp\v201711\ReportQueryAdUnitView;
use Google\AdsApi\Dfp\v201711\ReportService;

/**
 * This example runs a typical daily inventory report and saves it in your
 * system's temp directory. It filters on the network's root ad unit ID. This is
 * only to demonstrate filtering for the purposes of this example, as filtering
 * on the root ad unit is equivalent to not filtering on any ad units.
 */
class RunInventoryReport {

  public static function runExample(DfpServices $dfpServices,
      DfpSession $session) {
    $reportService = $dfpServices->get($session, ReportService::class);
    $networkService = $dfpServices->get($session, NetworkService::class);

    // Get the network's root ad unit ID to filter on.
    $rootAdUnitId =
        $networkService->getCurrentNetwork()->getEffectiveRootAdUnitId();

    // Create statement to filter on a parent ad unit with the root ad unit ID
    // to include all ad units in the network.
    $statementBuilder = (new StatementBuilder())
        ->where('PARENT_AD_UNIT_ID = :parentAdUnitId')
        ->withBindVariableValue('parentAdUnitId', intval($rootAdUnitId));

    // Create report query.
    $reportQuery = new ReportQuery();
    $reportQuery->setDimensions([
        Dimension::AD_UNIT_ID,
        Dimension::AD_UNIT_NAME
    ]);
    $reportQuery->setColumns([
        Column::AD_SERVER_IMPRESSIONS,
        Column::AD_SERVER_CLICKS,
        Column::DYNAMIC_ALLOCATION_INVENTORY_LEVEL_IMPRESSIONS,
        Column::DYNAMIC_ALLOCATION_INVENTORY_LEVEL_CLICKS,
        Column::TOTAL_INVENTORY_LEVEL_IMPRESSIONS,
        Column::TOTAL_INVENTORY_LEVEL_CPM_AND_CPC_REVENUE
    ]);
    // Set the filter statement.
    $reportQuery->setStatement($statementBuilder->toStatement());
    // Set the ad unit view to hierarchical.
    $reportQuery->setAdUnitView(ReportQueryAdUnitView::HIERARCHICAL);
    // Set the start and end dates or choose a dynamic date range type.
    $reportQuery->setDateRangeType(DateRangeType::YESTERDAY);

    // Create report job and start it.
    $reportJob = new ReportJob();
    $reportJob->setReportQuery($reportQuery);
    $reportJob = $reportService->runReportJob($reportJob);

    // Create report downloader to poll report's status and download when ready.
    $reportDownloader =
        new ReportDownloader($reportService, $reportJob->getId());
    if ($reportDownloader->waitForReportToFinish()) {
      // Write to system temp directory by default.
      $filePath = sprintf(
          '%s.csv.gz',
          tempnam(sys_get_temp_dir(), 'inventory-report-')
      );
      printf("Downloading report to %s ...\n", $filePath);
      // Download the report.
      $reportDownloader->downloadReport(ExportFormat::CSV_DUMP, $filePath);
      print "done.\n";
    } else {
      print "Report failed.\n";
    }
  }

  public static function main() {
    $oAuth2Credential = (new OAuth2TokenBuilder())
        ->fromFile('src/Google/AdsApi/Common/Testing/adsapi_php.ini')
        ->build();
    $session = (new DfpSessionBuilder())
        ->fromFile('src/Google/AdsApi/Common/Testing/adsapi_php.ini')
        ->withOAuth2Credential($oAuth2Credential)
        ->build();
    self::runExample(new DfpServices(), $session);
  }
}

RunInventoryReport::main();

我使用的是Googleads lib API版本:v201711

请帮我解决这个问题

0 个答案:

没有答案