Instagram API - get posts from single user
<p>I am really struggling to work with the Instagram API. I currently have this code in a file called <code>data.php</code> which I want to return a JSON response which I can process in a JS file but I am getting this response <code>failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request</code></p>

<p>Here is the code:</p>

<pre><code>&lt;?php

$access_token = '********';
$client_id = '********';
$client_secret = "*******";
$user = "*******";

$endpoint = '/media/657988443280050001_25025320';
$params = array(
  'access_token' =&gt; '********',
  'count' =&gt; 10,
);

$signature = generate_sig($endpoint, $params, $client_secret);

var_dump("Signature: ". $signature);

$data = file_get_contents("https://api.instagram.com/v1/users/$user/media/recent/?access_token=$signature");

header('Content-Type: application/json; charset=UTF-8');
echo $data;

function generate_sig($endpoint, $params, $secret) {

  $sig = $endpoint;

  ksort($params);

  foreach ($params as $key =&gt; $val) {
    $sig .= "|$key=$val";
  }

  return hash_hmac('sha256', $sig, $secret, false);

}
</code></pre>

<p>?></p>

<p>Here are my app settings. It is in <code>Sandbox Mode</code> and hasn't been submitted for review.</p>

<p><a href="https://i.stack.imgur.com/ptt5o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ptt5o.png" alt="enter image description here"></a></p>