SOAP错误:解析WSDL:无法从中加载 [英] SOAP-ERROR: Parsing WSDL: Couldn't load from
问题描述
我正在将google Adwords API集成到我的网络应用程序中,即在执行我的php文件时出错,即
I am integrating google Adwords API in my web appllcation ,I getting an error while executing my php file i.e
错误:
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 )
推荐答案
问题出在SSL上.如果您正在本地测试API并遇到此错误,请尝试快速检查-在AdWords PHP SDK中找到名为AdsSoapClientFactory.php
的文件,并在第142行进行更新以添加&& false
:
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
在该代码行下面也有一些有用的注释.当然,不建议在生产系统中禁用SSL验证,但是至少这可以是一种快速的解决方案,不要让您忘记为什么该死的API不想起作用.
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.
如果这确实解决了问题,请考虑使用SoapSettings实施它.撤消对AdsSoapClientFactory.php
所做的更改,然后在您的主文件中添加:
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();
这篇关于SOAP错误:解析WSDL:无法从中加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!