-1

I'm trying to load Json array from this URL

What I tried so far is following:

//By Using File_get_contents()

$insta_source = file_get_contents($url);
$insta_array = json_decode($insta_source, TRUE);    
var_dump($insta_array);

//AND
//By Using php CURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$server_output = curl_exec ($ch);
curl_close ($ch);
var_dump($server_output);

//As in output it gives "Bool(false)" (get_file_contents())
//Curl Error gives : "bool(true)" but not the json array

Many Thanks, Jim

Qcr Technologies
  • 91
  • 1
  • 2
  • 8

1 Answers1

0

If you want the content of a cURL request, you have to use the CURLOPT_RETURNTRANSFER setting, as mentioned on http://www.php.net/curl_exec:

Returns TRUE on success or FALSE on failure. However, if the CURLOPT_RETURNTRANSFER option is set, it will return the result on success, FALSE on failure.

So you just need to enable the CURLOPT_RETURNTRANSFER setting.

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
Progman
  • 16,827
  • 6
  • 33
  • 48