php - using json data from Curl response -
php - using json data from Curl response -
hi i'm little new @ curl, i'm trying request json info , parse results. having success retrieving data, can't handle response. here's code
function bitbucketcurl($url) { global $bitpassword; global $bitusername; $ch = curl_init(); // set url , other appropriate options curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_userpwd, "$bitusername:$bitpassword"); curl_setopt($ch, curlopt_header, 0); // grab url , pass browser $commitinfo = curl_exec($ch); // close curl resource, , free scheme resources curl_close($ch); homecoming $commitinfo; } $json = bitbucketcurl($url); echo $json; // seems work in that, when load page, can see json info //turn json info array - not seem working $obj_a = json_decode($json, true); print_r ($obj_a); //the result 1 rather array expect
the basic problem json info shows when echo $json
when seek turn info array doesn't work. when print array, '1'.
i got required result adding next line:
curl_setopt($ch, curlopt_returntransfer, 1);
php json curl
Comments
Post a Comment