title: PHP CURL redirect
body: <p>im pretty new in php. Current I'm facing problem about php curl post and redirection. I had wrote plenty of code to connect a cross-domain api. In this API, the response will be redirect my page into another page. </p>
  
  <p>so, now what I'm facing was I can't follow the api response as well.
  It means in my php scripts, my curl had receive the redirection page web content but my page still remaining. </p>
  
  <p>May I know is php curl can be follow the API redirection?</p>
  
  <p>Is there anyone know how to solve this issue?  </p>
  
  <p>Below will be my code.</p>
  
  <pre><code>$url = "http://www.google.com.my"; //example this is an API
  $ch = curl_init();
  curl_setopt ($ch, CURLOPT_URL, $url);
  curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
  curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt ($ch, CURLOPT_REFERER, $url);
  curl_setopt ($ch, CURLOPT_POSTFIELDS, $data_string);
  curl_setopt ($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($data_string))); 
  
  $result = curl_exec($ch);
  $response = curl_getinfo($ch);
  curl_close($ch); 
  </code></pre>
  
  <p>In the $result, i had receive the API redirect page. But it is only web content.</p>