trying to get property of non object curl issue

Posted by user550265 on Stack Overflow See other posts from Stack Overflow or by user550265
Published on 2011-02-17T15:15:12Z Indexed on 2011/02/17 15:25 UTC
Read the original article Hit count: 192

Filed under:

I have a curl setup as follows to access a json object

$ch = curl_init();

 curl_setopt($ch, CURLOPT_URL, "http://sitename.com");

 curl_setopt($ch, CURLOPT_HEADER, 0);

 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

 curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);

 curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookiefilename.txt');


 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host:sitename.com'));

 $output = curl_exec($ch);

 curl_close($ch);
 $output = json_decode($output);
 echo $output->property;

I get the error 'trying to access property of non object'.

© Stack Overflow or respective owner

Related posts about php