php - Setting plimus API in order to fetch an authentication token -


i need set plimus api in order fetch authentication token , use log customer plimus platform.

i'm using following code:

    $url = "https://sandbox.plimus.com/services/2/tools/auth-token?shopperid=$shopperid&expirationinminutes=$expiration";  // use base64 encode credentials $authorization = base64_encode($username.':'.$password);   $ch = curl_init(); // set url curl_setopt_array($ch, array(curlopt_url => $url)); // set headers curl_setopt($ch, curlopt_httpheader, array("authorization: basic $authorization", "content-type: application/xml")); // line mandatory every api call! // set  http request curl_setopt($ch, curlopt_customrequest, "get"); // service (get token) implement via restful get, other services might use post , put // stop output of curl_exec standard output (don't send output screen) curl_setopt($ch,curlopt_returntransfer,1); // make http call , read response xml object  $xml = new simplexmlelement(curl_exec($ch));  // -------- part ii - log customer plimus (according $target) --------  // construct plimus url $plimus = "https://sandbox.plimus.com/jsp/entrance.jsp?contractid=$contractid&target=$target&token={$xml->token}"; // redirect header("location: $plimus"); 

and following error , don't know why:

fatal error: uncaught exception 'exception' message 'string not parsed xml' in xxx\get_token.php:40 stack trace: #0 xxx\get_token.php(40):  simplexmlelement->__construct('') #1 {main} thrown in xxx\get_token.php on line 40 

thanks

it looks it's code, taken second part of article: how improve customer-experience , conversion api
:)

use var_dump(curl_exec($ch)) , see exact response you're getting server!


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -