I am trying to authenticate to third party ticketing system, connect and retrieve agent info. I then want to parse retrieved file so as to only show specific info such as 'id' and' 'active_since', but I get an NULL error in browser. Any help?
FILE RETURNED BY THIRDPARTY
[agent] => Array ( [active_since] => 2015-11-30T08:09:26-01:00 [available] => 1 [created_at] => 2015-05-14T19:15:18+00:00 [id] => XXXXX [occasional] => [points] => 5520 [scoreboard_level_id] => 5000402007 [signature] => [signature_html] =>
Below is the PHP CURL code.
<?php $username = "xxxxxxx"; $password = "xxxxxxx"; $url = 'http://support.xxxx.com/agents/xxx132067'; $cURL = curl_init(); curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($cURL, CURLOPT_URL, $url); curl_setopt($cURL, CURLOPT_HTTPGET, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Accept: application/json', 'header' => "Authorization: Basic " . base64_encode("$username:$password") ) ); $result = file_get_contents($url); // Will dump a beauty json :3 var_dump(json_decode($result, true)); $array["active_since"]; ?>
No comments:
Post a Comment