JSON REST request with PHP response as variable
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKPz5qhCkKGdpPJ0wkSm5JqlliSJoZg92-H4DuCruovhkVFuXerCphZt9wys_Gr3uwQyXObMHDwattjG5BSeCEl_LdDq1GPLct8qYyRyX4fZ9C93oW-TX7IGZLYDwqRgfFCXA4aUxkBAcS/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6VebLk98DYwS3K2nWZSCatab-q4HrSuRk91M4fQA8SHrKU_-x-lq1n780pSU_bIVLqMRv6pc3dhhh-Y2PUwBS9mM0BxvY1eM6XsM-e7Diu4z-wAoeDG0vB3-2_1U9RE8sO0lg4PHiIXbI/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
JSON REST request with PHP response as variable
I am trying to get the following request on headers Accept: application/json
Content-Type: application/json
"userVO":
"userId": "899",
"lstAuthToken":" uYCpPz6LTYVAZBee8SHrB9I1Ak2nxH9Xfi%2F2cy5ZwFk%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 GuzzleHttpClient();
$res = $client->get('http://54.84.41.76/wkconnects/rest/manageLST/generateLSTAuthToken', [
'auth' => ['899', 'uYCpPz6LTYVAZBee8SHrB9I1Ak2nxH9Xfi%2F2cy5ZwFk%3D']
]);
echo $res->getStatusCode(); // 200
echo $res->getHeader('content-type'); // 'application/json; charset=utf8'
echo $res->getBody(); // {"type":"User"...'
var_export($res->json());
?>
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Comments
Post a Comment