SOAP-ERROR: Parsing WSDL: Couldn't load from

强颜欢笑 提交于 2019-12-04 06:36:14

问题


I am integrating google Adwords API in my web appllcation ,I getting an error while executing my php file i.e

Error:

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 )

回答1:


The problem is with SSL. If you are testing the API locally and getting this error, try a quick check - find in the AdWords PHP SDK the file named AdsSoapClientFactory.php and update around line 142 to add && false:

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

There are some useful comments below that code line as well. Of course, disabling SSL verification is not recommended for production systems, but at least this can be a quick solution to not lose your mind over why the damn API doesn't want to work.

If this indeed solves the problem, consider implementing it with SoapSettings. Undo the changes to AdsSoapClientFactory.php, and in your main file add:

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

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


来源:https://stackoverflow.com/questions/27700362/soap-error-parsing-wsdl-couldnt-load-from

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!