3

我对 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() 的功能?这似乎是唯一的问题。

4

0 回答 0