2014-12-30 133 views
0

加載我整合谷歌的Adwords API在我的web appllcation,在執行我的PHP文件即SOAP的錯誤:解析WSDL:無法從

錯誤我得到一個錯誤:

Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in /var/www/vhosts/healthcampaign.in/httpdocs/smscampaign/pages/FacebookAds.php on line 187 
SoapFault Object ([message:protected] => SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://adwords-sandbox.google.com/api/adwords/cm/v201406/CampaignService?wsdl' : 
failed to load external entity "https://adwords-sandbox.google.com/api/adwords/cm/v201406/CampaignService?wsdl" 
    [string:Exception:private] => [code:protected] => 0 [file:protected] => /var/www/vhosts/healthcampaign.in/httpdocs/smscampaign/pages/FacebookAds.php [line:protected] => 219 
    [trace:Exception:private] => Array ([0] => Array ( 
                 [file] => /var/www/vhosts/healthcampaign.in/httpdocs/smscampaign/pages/FacebookAds.php [line] => 219 
                 [function] => SoapClient 
                 [class] => SoapClient 
                 [type] => -> [args] => Array ( 
                         [0] => https://adwords-sandbox.google.com/api/adwords/cm/v201406/CampaignService?wsdl 
                         [1] => Array ([trace] => 1) 
                         ) 
                ) 
    ) 
    [previous:Exception:private] => [faultstring] => SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://adwords-sandbox.google.com/api/adwords/cm/v201406/CampaignService?wsdl' : 
    failed to load external entity "https://adwords-sandbox.google.com/api/adwords/cm/v201406/CampaignService?wsdl" [faultcode] => WSDL) 

回答

0

由於錯誤消息說... WSDL URL無效。嘗試使用這一個:

https://adwords.google.com/api/adwords/cm/v201409/CampaignService?wsdl 
2

問題出在SSL。如果你是在本地測試API和收到此錯誤,請嘗試一個快速檢查 - 在AdWords PHP SDK命名爲AdsSoapClientFactory.php和更新周圍線142要添加的文件&& false

// SSL settings. 
if ($soapSettings->getSslVerify() === true && false) { // explicitly disable SSL Verify 

下面有一些有用的意見代碼行也是如此。當然,不建議在生產系統中禁用SSL驗證,但至少這可以是一個快速解決方案,不要爲了該死的API不想工作而失去主意。

如果這確實解決了這個問題,可以考慮使用SoapSettings來實現它。撤消更改爲AdsSoapClientFactory.php,並在您的主文件中添加:

use Google\AdsApi\Common\SoapSettingsBuilder; 
[...] 
$soapSettings= (new SoapSettingsBuilder()) 
    ->disableSslVerify() 
    ->build(); 

$session = (new AdWordsSessionBuilder()) 
    ->fromFile() 
    ->withOAuth2Credential($oAuth2Credential) 
    ->withSoapSettings($soapSettings) 
    ->build(); 
相關問題