One the issues is that the twitter-sync library utilizes multicurl
which allows for parallel requests.  Introducing this type of logic is
tricky since the library allows you to access the results "later" and
only at that point can we inspect the headers.  Most people probably
use it in a manner where they immediately block for the results, but I
don't think sacrificing the ability to do parallel requests is worth
following 302s.

Anyways, I'd like to know from Twitter what their plans are for the
302 redirects.  Is it temporary?  It's far from an ideal solution and
seems more like a stop gap.  However, I don't think they'll chime in
on this thread due to the title.  Perhaps a new general thread would
be appropriate.

Jaisen

On Sep 1, 7:06 pm, fbparis <fbou...@gmail.com> wrote:
> I've just coded this function which may help :
>
> function redirect_post($url,$data) {
>         $ch = curl_init($url);
>         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
>         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
>         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
>         curl_setopt($ch, CURLOPT_HEADER, true);
>
>         curl_setopt($ch, CURLOPT_POST, 1);
>         curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
>
>         list($header,$content) = preg_split("#(\r)?\n(\r)?\n#s",curl_exec
> ($ch),2);
>         $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
>
>         curl_close($ch);
>
>         if (in_array($http_code,array(301,302))) {
>                 $redir = preg_match("#Location:(.*?)\n#si",$header,$m) ? 
> trim($m
> [1]) : '';
>                 if ($redir && ($redir != $url)) return 
> redirect_post($redir,$data);
>         }
>
>         return $content;
>
> }
>
> I've tested, it's ok ; and shouldn't be so hard to use in the lib.
>
> I'll have to use the Jaisen Mathai OAuth library very soon too, so if
> no solution has been found I'll post mine here :)
>
> FB

Reply via email to