Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://www.dyn-web.com/tutorials/php-js/json/decode.php
- https://stackoverflow.com/questions/12429029/php-get-values-from-json-encode
- https://stackoverflow.com/questions/20193575/fetch-json-data-using-php
- https://stackoverflow.com/questions/12429029/php-get-values-from-json-encode
- https://stackoverflow.com/questions/4433951/decoding-json-after-sending-using-php-curl
- array(1) {
- ["login"]=>
- array(2) {
- ["error"]=>
- bool(false)
- ["user"]=>
- array(5) {
- ["br_code"]=>
- int(0)
- ["mem_id"]=>
- int(202)
- ["username"]=>
- string(8) "johndoe"
- ["email"]=>
- string(33) "johndoe@gmail.com"
- ["created_at"]=>
- string(19) "2017-08-07 15:35:39"
- }
- }
- }
- <?php
- session_start();
- $ch = curl_init('http://localhost/sample/login.php');
- $username= $_SESSION["USERNAME"];
- $password= $_SESSION["PASSWORD"];
- $credentials = [
- 'username' => $username,
- 'password' => $password
- ];
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $credentials);
- curl_setopt($ch, CURLOPT_USERNAME, "{$username}:{$password}");
- // execute!
- $response = curl_exec($ch);
- // close the connection
- curl_close($ch);
- $obj= json_decode($response, true);
- // echo $obj; // Notice: Array to string conversion in
- // echo $obj[0]; // Undefined offset
- // echo $obj->user; //Trying to get property of non-object in
- var_dump($obj);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement