我对NuSoap了解不多,但不幸的是我 使用它。 我正在尝试关注dotmailer web服务api Here的示例代码。我需要能够为订阅者添加自定义字段。
在示例代码中,自定义/附加字段的定义如下;
new SoapVar($FirstName,XSD_STRING,"string","http://www.w3.org/2001/XMLSchema");
这是我现在拥有的代码;
<?php
function subscribeUserEmail($email)
{
$username = "********";
$password = "********";
$postURL = "http://apiconnector.com/api.asmx?WSDL";
$contact = array (
"Email" => $email,
"AudienceType" => "B2C",
"OptInType" => "Single",
"EmailType" => "Html",
"ID" => -1,
"DataFields" => array(
"Keys" => array("TEST"),
"Values" => array("Name")
)
);
$params = array(
"username" => $username,
"password" => $password,
"contact" => $contact,
"addressbookId" => "******"
);
$client = new soapclient($postURL, true);
$error = $client->getError();
$result = $client->call('AddContactToAddressBook', $params);
echo "<h2>Request</h2>";
print("<pre>".$client->request."</pre>");
echo "<h2>Response</h2>";
print("<pre>".$client->response."</pre>");
echo "<h2>Debug</h2>";
print("<pre>".$client->debug_str."</pre>");
}
?>
如果$contact
数组更改为此;
$contact = array (
"Email" => $email,
"AudienceType" => "B2C",
"OptInType" => "Single",
"EmailType" => "Html",
"ID" => -1,
"DataFields" => array(
"Keys" => array("TEST"),
"Values" => array(new SoapVar("Name",XSD_STRING,"string","http://www.w3.org/2001/XMLSchema") )
)
);
与普通肥皂客户端一起使用,代码可以运行。所以我很确定我的功能没有任何其他问题。
我尝试过使用以下内容;
new soapval("string", XSD_STRING, "Name","http://www.w3.org/2001/XMLSchema");
作为SoapVar()方法的替代方法,但是我得到了相同的错误,就像我将值作为纯文本输入一样。
如何在NuSoap中复制SoapVar()的功能?这似乎是唯一的问题。