0

I am trying to get the following request on headers Accept: application/json Content-Type: application/json

{
  "userVO": {
     "userId": "899",
    "lstAuthToken":" uYCpPz6LTYVAZBee8S2cy5ZwFk%3D"
    }
}

sent to the URL of the following: http://54.84.41.76/wkconnects/rest/manageLST/validateLSTAuthToken for validation. I will get the response of:

{
  "ccVerified": "true",
  "sessionAuthenticationToken": "KAA93bndyYaVPCVa8Sx%2FqLomPUP0CSBVHLRBQKMy3e9N%2FnYBEdjXHoN0lmxLfRwljH3PpkeOLIYS%0AQ4WVhF14015bz22HOAq%2B%2FBzMfzI3Z3jFmcuPDhZ6UGGv691Q1azHuQq8U7Biz8DSkPZV0qznohjD%0A43AhVR03LLFcffHI3do%3D",
  "status": "true"
}

I need to get the response ccVerifiedand sessionAuthenticationToken as variables so I can say =true or =false etc.

I tried using the following with little success:

<?php
$client = new GuzzleHttp\Client();
$res = $client->get('http://54.84.41.76/wkconnects/rest/manageLST/generateLSTAuthToken', [
    'auth' =>  ['899', 'uYCpPz6LTYVAZBeH9Xfi%2F2cy5ZwFk%3D']
]);
echo $res->getStatusCode();           // 200
echo $res->getHeader('content-type'); // 'application/json; charset=utf8'
echo $res->getBody();                 // {"type":"User"...'
var_export($res->json());     
?>
3
  • you forgot to tell us what the problem is! Commented Jul 29, 2018 at 20:23
  • and you shouldn't post a real authToken here. Please refresh it now. Commented Jul 29, 2018 at 20:25
  • empty page response Commented Jul 29, 2018 at 20:32

1 Answer 1

1

sorry im doing stuff like this mostly with curl

<?php                                                                    
    $data_string = json_encode(["userVO" => ['userId' => 899, 'lstAuthToken' => 'token']]);                                                                                                                           
    $ch = curl_init('http://54.84.41.76/wkconnects/rest/manageLST/generateLSTAuthToken');                                                                      
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
    curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json', 'Content-Length: ' . strlen($data_string)]);                                                                                                                   
    $result = json_decode(curl_exec($ch));
    if($result->status == "true"){
        $lstAuthToken = $result->lstAuthToken;
        $sessionAuthenticationToken = $result->sessionAuthenticationToken;
    }
    else{
        echo "something went wrong";
    }

    ?>
Sign up to request clarification or add additional context in comments.

7 Comments

AMAZING YOU ROCK STEFAN!
On a side note, how would that type of response be able to help with determine whether to send someone to a credit card failure, or cc success page?
btw im not sure, i can send this req withouth any token and get a true back
i dont understand what u mean but u can do print_r($result) and get everything u get as result
The value for "lsttokenauth" will be dynamic.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.