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