Reputation: 114
I am trying to parse the JSON response from PHP. How can i get values from JSON response by keys.Thanks in advance.
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,'https://www.instamojo.com/api/1.1/payment-requests/');
curl_setopt($ch,CURLOPT_HTTPHEADER,array('X-Api-Key: SomeKEY','X-Auth-Token: SomeToken'));
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,http_build_query($req_data,'','&'));
curl_setopt($ch,CURLOPT_TIMEOUT,130);
$json= curl_exec($ch);
if($err=curl_error($ch)) {
var_dump($err);
}
var_dump($json);
$jsonArray= json_decode($json,true);
Upvotes: 0
Views: 623
Reputation: 1777
$jsonArray['payment_request']['longurl']
should have the long url value you are looking for.
Hope it helps.
Upvotes: 1