我正在使用在http://help.exacttarget.com/en/technical_library/web_service_guide/api_starter_kits/上找到的确切目标PHP API入门工具包,并尝试使用示例代码进行连接。作为参考,下面是提供的示例代码:
<?php
echo '<pre>';
require('../../00 Includes/exacttarget_soap_client.php');
<?php
echo '<pre>';
require('../../00 Includes/exacttarget_soap_client.php');
$wsdl = 'https://webservice.s6.exacttarget.com/Service.asmx';
try{
/* Create the Soap Client */
$client = new ExactTargetSoapClient($wsdl, array('trace'=>1));
/* Set username and password here */
$client->username = '<ommitted>';
$client->password = '<omitted>';
$request = new ExactTarget_RetrieveRequest();
$objectType= "Subscriber";
$request->ObjectType= $objectType;
$request->Properties = array("ID","PartnerKey","CreatedDate","Client.ID","Client.PartnerClientKey","EmailAddress","SubscriberKey","UnsubscribedDate","StatusSubscriberStatus");
// Filter retrieve on a particular email address
$filter1 = new ExactTarget_SimpleFilterPart() ;
$filter1->Property= "EmailAddress";
$filter1->SimpleOperator=ExactTarget_SimpleOperators::equals;
$filter1->Value=array("info@exacttarget.com"); //email address to filter on
$request->Filter = new SoapVar($filter1, SOAP_ENC_OBJECT, 'SimpleFilterPart', "http://exacttarget.com/wsdl/partnerAPI");
$requestMsg = new ExactTarget_RetrieveRequestMsg();
$requestMsg->RetrieveRequest=$request;
$results = $client->Retrieve($requestMsg);
/* Output the results */
echo 'Results:';
var_dump($results);
} catch (SoapFault $e) {
/* output the resulting SoapFault upon an error */
var_dump($e);
}
/* Output the request and response */
print "Request: n". $client->__getLastRequestHeaders() ."n";
print "Request: n".
$client->__getLastRequest() ."n";
print "Response: n".
$client->__getLastResponseHeaders()."n";
print "Response: n".
$client->__getLastResponse()."n";
echo '</pre>';
?>
当我运行这段代码时,我遇到了一个异常消息:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://webservice.s6.exacttarget.com/Service.asmx' : Entity 'nbsp' not defined
我以前使用过确切的目标API,有两个奇怪的事情:
- 错误发生在第10行,并且在SoapClient构造函数中触发,该构造函数由exacttarget_soap_client类继承。
- 我已经分配了一个用户名,其中有一个空格。
- 原来的API工具包使用wsdl url https://webservice.exacttarget.com/etframework.wsdl,它提供了一个"不正确的端点"错误。因此,我使用https://salesforce.stackexchange.com/questions/44614/request-was-made-to-the-incorrect-endpoint上列出的每个端点进行了尝试。使用任何一个端点,我得到实体未定义错误。
还有其他人遇到这个问题吗?
对于s6实例,我需要将url更改为https://webservice.s6.exacttarget.com/etframework.wsdl。此外,入门工具包似乎还有其他一些过时的代码。我提到了这个确切的目标,他们下架了php(非燃料)版本。