1

I have used curl to extract data as follows

$ch = curl_init();

 curl_setopt($ch, CURLOPT_URL, "http://sitename.com");
 curl_setopt($ch, CURLOPT_HEADER, 0);
 curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
 curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookiefilename.txt');
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host:http://sitename.com'));
 $output = curl_exec($ch);
 curl_close($ch);
 $output = json_decode($output);
 cache_set($tableid,$output,'cache',strtotime("midnight +1 day +1 hour"));

However i am not getting anything in the $output object.

1
  • Use curl_error() to see whether there are any errors Commented Feb 16, 2011 at 23:09

2 Answers 2

2

Try

var_dump($output) 

to see what the value is. You can also try

var_dump(curl_error($ch));

to see if curl will tell you what's wrong.

Sign up to request clarification or add additional context in comments.

Comments

0

If the output you receive from your curl_exec($ch) is not JSON, you'll get nothing out of json-decode($output). Is it JSON that you are expecting?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.