file_get_contents not displaying any data
Posted
by
Lance
on Stack Overflow
See other posts from Stack Overflow
or by Lance
Published on 2013-10-30T15:46:11Z
Indexed on
2013/10/30
15:53 UTC
Read the original article
Hit count: 153
I'm doing
$info = file_get_contents('http://USERNAME:[email protected]/v2/sales?client_key=CLIENT_KEY');
$info
returns nothing. However, when I put the URL into my browser, JSON appears. I tried using cURL without any luck.
$data = array('client_key' => 'CLIENT_KEY');
$link = "http://api.appfigures.com/v2/sales";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_USERPWD, "username:password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$jsonData = curl_exec($ch);
curl_close($ch);
print_r($jsonData);
Thanks
© Stack Overflow or respective owner