I want to get a json array from an API.
Why cant I get it using file_get_contents($g_7_14)
?
This is the error I get:
( ! ) Warning: file_get_contents(https://example.com:443/api/xxx/yyy?app_ids=666&start_date=2015-07-14&end_date=2015-07-14&auth_token=8sCR): failed to open stream: HTTP request failed! HTTP/1.1 406 Not Acceptable in C:\wamp\www\PHPExcel\index.php on line 8
and this is my code:
<?php
//494792609
if ( !empty ( $_GET['app_id'] ) ) {
$g_7_14 = 'https://example.com:443/api/xxx/yyy?app_ids=666&start_date=2015-07-14&end_date=2015-07-14&auth_token=8sCR';
echo $g_7_14.'<br>';
$json_g_7_14 = file_get_contents($g_7_14);
/* $ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$g_7_14);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_HTTPHEADER,array('Accept-Encoding: gzip'));
$xml_response = curl_exec($ch);
var_dump($xml_response);
*/
$a_g_7_14 = json_decode($json_g_7_14, true);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>YH </title>
</head>
<body>
<form action="">
<input type="text" name="app_id" />
<button type="submin"> submit</button>
</form>
<div>
<?php
?>
</div>
</body>
</html>
You can see in the code I got a cURL part which is commented. Didn't work too :( !