title: Getting a tricky shortURL redirect
body: <p>I have often used either php get_headers() or cURL to resolve long URLs from short URLs. I'm having trouble with short URLS from Oktopost, such as this example: <a href="http://okt.to/4AOy96" rel="nofollow">http://okt.to/4AOy96</a></p>
  
  <p>Headers indicate there is no redirect from this URL, just returning <a href="http://okt.to/4AOy96" rel="nofollow">http://okt.to/4AOy96</a>:</p>
  
  <pre><code>Array
  (
  [0] =&gt; HTTP/1.1 200 OK
  [1] =&gt; Content-Type: text/html
  [2] =&gt; Date: Wed, 10 Jun 2015 05:27:09 GMT
  [3] =&gt; Server: Apache/2.4.7 (Ubuntu)
  [4] =&gt; Vary: Accept-Encoding
  [5] =&gt; X-Powered-By: PHP/5.5.9-1ubuntu4.7
  [6] =&gt; Content-Length: 914
  [7] =&gt; Connection: Close
  )
  </code></pre>
  
  <p>But when I paste this link into a browser it IS redirecting me to a different destination page. Does that suggest some type of redirection on the part of the Oktopost server, which is just not "followable" via a typical header location? A little confused about what might be going on here.</p>
  
  <p><strong>ADDITIONAL INFO</strong></p>
  
  <p>As per the recommendations below, I'm trying to get back a cURL response so I can parse the meta refresh and get the URL that I need. Problem is, all my cURL attempts are getting stuck in an infinite loop. I've tried any number of option combinations, but with no luck.</p>
  
  <pre><code>$ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'http://okt.to/4AOy96');
  //curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.6 (KHTML, like Gecko) Chrome/16.0.897.0 Safari/535.6'); 
  //curl_setopt($ch, CURLOPT_HEADER, true);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
  curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  $html = curl_exec($ch);
  curl_close($ch);
  echo $html;
  </code></pre>
  
  <p>Just can't seem to kill the loop and get back the html.</p>