开发者

cURL fetch a facebook api page

I don't even have slightest of clue of what i am doing wrong here.My head's all messed up.

So basically i want to fetch https://www.facebook.com/dialog/stream.publish?access_token=bla-bla this page for some form data. I am using php cURL lib for that.My actual code base is like--

$furl='https://www.facebook.com/dialog/stream.publish?access_token=bla-bla&other-pram';
$cookie_string="";
foreach( $_COOKIE as $key => $value ) {
  $cookie_string .= "$key=$value;";
};
$curl=curl_init();
curl_setopt($curl,CURLOPT_URL,$furl);
curl_setopt ($curl, CURLOPT_REFERER,'m开发者_StackOverflow社区y domain');
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt ($curl, CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
curl_setopt ($curl, CURLOPT_COOKIE,$cookie_string); 
curl_setopt($curl, CURLOPT_ENCODING, "");
$buffer = curl_exec($curl);
curl_close($curl);
//var_dump($buffer);
if (empty($buffer))
{
    print "Sorry,no content.";
}
else
{
    print $buffer;
}

This $furl work just fine in browser.But in my server it shows something like--

HTTP/1.1 200 OK Cache-Control: private, no-cache, no-store, must-revalidate Expires: Sat, 01 Jan 2000 00:00:00 GMT P3P: CP="Facebook does not have a P3P policy. Learn why here: http://fb.me/p3p" Pragma: no-cache Set-Cookie: __utma=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly Set-Cookie: __utmb=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly Set-Cookie: __utmc=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly Set-Cookie: __utmz=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly Set-Cookie: _e_Jjuf_0=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly Set-Cookie: c1=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly Set-Cookie: c2_top=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly Set-Cookie: ck_expr=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly Set-Cookie: ckmsg=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly Set-Cookie: datr=vG1BThzB5emc65eco5mEIJt-; expires=Thu, 08-Aug-2013 17:26:20 GMT; path=/; domain=.facebook.com; httponly Set-Cookie: fb_ss=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly Set-Cookie: fbs_undefined=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly Set-Cookie: locale=en_US; expires=Tue, 16-Aug-2011 17:26:20 GMT; path=/; domain=.facebook.com Set-Cookie: lsd=_G6Yd; path=/; domain=.facebook.com Set-Cookie: PHPSESSID=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly Set-Cookie: wd=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly Content-Encoding: gzip Content-Type: text/html; charset=utf-8 X-FB-Server: 10.63.23.62 X-Cnection: close Transfer-Encoding: chunked Date: Tue, 09 Aug 2011 17:26:20 GMT

So it means i am LOGED OUT.But yet i can access FB from browser.Do have to change cURL ??I don't even understand where to start looking... :-[ Any help w'll be appreciated greatly.

EDIT:code updated.


You're using a POST method, which is usually used to SEND data to a site. Most likely you want to use a GET instead. Since GET is curl's default if you don't otherwise specify, simply remove the CURLOPT_POST line.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜