1

我正在尝试让 viapost 的登录部分正常工作。

我正在使用 API 的这一部分:https ://api.viapost.com/viapostcustomer.asmx?op=SignIn

这是我的那个片段的版本:

            <?php
            require_once('lib/nusoap.php');

            $endpoint = "http://api.viapost.com/SignIn";

            $client = new nusoap_client($endpoint, false);

            $xml ='<?xml version="1.0" encoding="utf-8"?>
            <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
              <soap:Body>
                <SignIn xmlns="http://api.viapost.com">
                  <sUserName>bradlyspicer@hotmail.co.uk</sUserName>
                  <sPassword>passwordhere</sPassword>
                  <sReturnMessage>Logged in Successfully</sReturnMessage>
                </SignIn>
              </soap:Body>
            </soap:Envelope>';

            $msg = $client->serializeEnvelope($xml);

            $result=$client->send($msg, $endpoint);

            print_r($result);

            ?>

密码本身在这里被替换,但我知道我的 100% 可以登录网站。

当我访问这个页面时。我没有回报。只是一个空白页

4

1 回答 1

1

尝试使用SoapClient.

<?php
class ViaPost
{
  private $wsdl = 'https://api.viapost.com/viapostcustomer.asmx?wsdl';
  private $client;
  private $token;

  public function __construct()
  {
    $this->client = new SoapClient($this->wsdl, array('trace' => true, 'soap_version' => SOAP_1_2));
  }

  public function SignIn($username, $password)
  {
    $result = $this->client->SignIn(array ('sUserName' => $username, sPassword => $password));
    $this->token = $result->sLoginToken;
  }
}

$viaPost = new ViaPost();
$viaPost->SignIn('bradly.spicer@', 'YourPassword');
?>
于 2013-08-27T17:07:04.377 回答