php - retrieve individual JSON data returned by cURL -


i used curl response of request, response given in json format , works fine, want specific data json response. when echo entire data, looks below

http/1.1 100 continue http/1.1 200 ok server: nginx/1.4.6 (ubuntu) date: fri, 29 jan 2016 10:54:22 gmt content-type: application/json;charset=utf-8 content-length: 379 status: 200 ok access-control-allow-origin: * set-cookie: __bakery_session=bah7bkkid3nlc3npb25fawqgogzfvekdm2ywi0mwzm%0aztbkztewytbiotblzmu0mwfmymu5ztlhzme5zde3nwfjnzg3ody0mdyxzdgg%0aowbg%0a--0f1dadab3b89c8d34eb184b42b0781ce12c8adf0; path=/; httponly set-cookie: rack.session=bah7bkkid3nlc3npb25fawqgogzfvekirwm0mwywownintyyodm2ywi0mwzm%0aztbkztewytbiotblzmu0mwfmymu5ztlhzme5zde3nwfjnzg3ody0mdyxzdgg%0aowbg%0a; path=/; httponly x-served-by: bakery-breadroute-biscuit,bakery-prime-jubilee {"id":17772310,"name":"phpkauykh","type":"image","created":"2016-01-29t10:54:22+00:00","updated":"2016-01-29t10:54:22+00:00","hashed_id":"enekkvawvr","description":"","progress":0.0,"status":"queued","thumbnail":{"url":"https://embed-ssl.wistia.com/deliveries/a70e7f7975ecb5f2bbf7b22e59f5d4d1112a4974.jpg?image_crop_resized=200x120","width":200,"height":120},"account_id":409257}

and code is:

<?php         if (isset($_post['submit'])) { $url = "https://upload.wistia.com/?access_token=38316d1a944b503fc4408e0325daf2ceb3b58558238aab8d87c7cb6e2de2360b&project_id=8mtrjz3g8l"; $filename = $_files['file']['name']; $filedata = $_files['file']['tmp_name']; //$filesize = $_files['photo']['size']; if ($filedata != '') { $headers = array("content-type:multipart/form-data"); // curl headers file uploading $postfields = array("filedata" => "@$filedata", "filename" => $filename); $ch = curl_init(); $options = array( curlopt_url => $url, curlopt_header => true, curlopt_post => 1, curlopt_httpheader => $headers, curlopt_postfields => $postfields, //curlopt_infilesize => $filesize, curlopt_returntransfer => true ); // curl options curl_setopt_array($ch, $options); $result=curl_exec ($ch);  echo $result."<br />"; echo '<br><br><br>+++++++++++++++++++++++++++++++++++++++++++++++++<br>'; //echo json_decode($result, true);  //echo curl_error($ch);  curl_close ($ch);  }  } ?>  <!doctype html> <html> <head> <title>livehacks.tv</title> <meta charset="utf-8"> <meta lang="en"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1">             <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> </head> <body>    <div class="left_signup_container"> <form name="wistia" method="post" action="<?php echo $php_self;?>" enctype="multipart/form-data" id="videoform"> <input type="file" name="file" id="file"> <input type="submit" class="btn btn-success" name="submit" id="submit" value="upload"> </form> </div>  </body> </html> 

it prints response, tried retrieve id data returns using below code, not working

json_decode($result, true); $id = $result->id; echo $id; 

any suggestions how can retrieve individual data in json array..!!

as returned data appears more json string, amend code add error checking.

also trying address id using object notation, great, dont bother converting json string array using ,true parameter.

json_decode($result);  if ( json_last_error() > 0 ) {    echo json_last_error_msg();    exit; }  echo $result->id; 

Comments