Вопрос

I am trying to get a signin segment of viapost to work.

I am using this part of the API: https://api.viapost.com/viapostcustomer.asmx?op=SignIn

Here is my Version of that snippet:

            <?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);

            ?>

The password itself is replaced here, but I know 100% mine works to login to the website.

When I visit the page this is on. I get no return. Just a blank page

Это было полезно?

Решение

Try using 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');
?>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top