title: cURL fetch a facebook api page
body: <p>I don't even have slightest of clue of what i am doing wrong here.My head's all messed up.</p>
  
  <p>So basically i want to fetch <code>https://www.facebook.com/dialog/stream.publish?access_token=bla-bla</code> this page for some form data.
  I am using php cURL lib for that.My actual code base is like--</p>
  
  <pre><code>$furl='https://www.facebook.com/dialog/stream.publish?access_token=bla-bla&amp;other-pram';
  $cookie_string="";
  foreach( $_COOKIE as $key =&gt; $value ) {
    $cookie_string .= "$key=$value;";
  };
  $curl=curl_init();
  curl_setopt($curl,CURLOPT_URL,$furl);
  curl_setopt ($curl, CURLOPT_REFERER,'my 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;
  }
  </code></pre>
  
  <p>This $furl work just fine in browser.But in my server it shows something like--</p>
  
  <p>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: <a href="http://fb.me/p3p" rel="nofollow">http://fb.me/p3p</a>" 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</p>
  
  <p>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.</p>
  
  <p><strong>EDIT:code updated.</strong></p>