title: HTTP curl failed 403 but success with Guzzle
body: <p>I'm trying to consume Instagram API for getting user feeds. With a normal curl I get 403, but it works fine using guzzle. I don't want to use a 3rd party. Any way to get it working with a curl?</p>
  
  <p>This is my code:</p>
  
  <pre><code>const INSTAGRAM_ENDPOINT = 'https://www.instagram.com/';
  const USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36';
  const QUERY_HASH = '42323d64886122307be10013ad2dcc44';
  
  $variables = [
      'id' =&gt; '232192182',
      'first' =&gt; '12',
      'after' =&gt; 'AQCWAl5VxOspHxLFduBo0kmKu0ILD-jynobaAJQBvRz8S1Vu1rDpz5KnyTADU4hxyOyHAsnrF_8RYXOYIXgwzbdUO41D2rfzL-PZN26HABDtoQ' // $this-&gt;endCursor,
  ];
  $endpoint = INSTAGRAM_ENDPOINT . 'graphql/query/?query_hash=' . QUERY_HASH . '&amp;variables=' . json_encode($variables);
  
  $hArray = [
      'User-Agent' =&gt; USER_AGENT,
      'X-Requested-With' =&gt; 'XMLHttpRequest',
      'X-Instagram-Gis' =&gt; 'cc2796cff28f2a3d71c73a4b61f62d84'
  ];
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $endpoint);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_HEADER, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $hArray);
  $server_output = curl_exec($ch);
  curl_close($ch);
  echo "&lt;br&gt;" . "&lt;br&gt;" . $server_output . "&lt;br&gt;" . "&lt;br&gt;";
  </code></pre>
  
  <p>Response:</p>
  
  <pre><code>HTTP/1.1 403 Forbidden Content-Type: text/html; charset=utf-8 x-robots-tag: noindex Cache-Control: private, no-cache, no-store, must-revalidate Pragma: no-cache Expires: Sat, 01 Jan 2000 00:00:00 GMT Vary: Cookie, Accept-Language Content-Language: en Date: Sat, 26 May 2018 09:22:28 GMT Strict-Transport-Security: max-age=86400 Set-Cookie: rur=FRC; Path=/ Set-Cookie: csrftoken=Vhh1ImCoyX1uMhfjZx65R9QbzewBsgzH; expires=Sat, 25-May-2019 09:22:28 GMT; Max-Age=31449600; Path=/; Secure Set-Cookie: mid=WwknVAAEAAFT3mN8ogObl6HSnQNy; expires=Fri, 21-May-2038 09:22:28 GMT; Max-Age=630720000; Path=/ Connection: keep-alive Content-Length: 0 
  </code></pre>
  
  <p>And the guzzle working code is:</p>
  
  <pre><code>$res = client-&gt;request('GET', $endpoint, ['headers' =&gt; $hArray]);
  $data = (string)$res-&gt;getBody();
  </code></pre>
  
  <p>I can't get it working even with postman! So, what guzzle do extra stuff to make it work?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Still need to get success with postman:</p>
  
  <p><a href="https://i.stack.imgur.com/2co4P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2co4P.png" alt="enter image description here"></a></p>