Currently, there is no tool or application to extract the names of fans of a "page" in facebook. So I decide to make my version of php
I use file_get_contents () with context, to choose the options header.
I want to convince Facebook that I want to load the lightbox listing the 100 by 100 fans as if I was on a standard web browser. The goal is to retrieve the html/javascript from the list to extract the names of fans.
I analyzed wireshark headers and cookies sent by my browser when he made the motion, so classic.
I then analyzed the response of facebook. The headers received are correct (200 OK). But I do not get the html as expected, but a boiled characters long not really readable.
Code:
//Headers sent
Host: www.facebook.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.0.15) Gecko/2009101601 Firefox/3.0.15 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
X-SVN-Rev: 199440
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://www.facebook.com/home.php
Content-Length: 167
Cookie:full of stuff that I tell you =D
Pragma: no-cache
Cache-Control: no-cache
//Body of the POST request
edge_type=fan&page=1&limit=100&class=FanManager&node_id=110534460377&post_form_id=0fb5daac8db470a1c972ff2efb84eeea&fb_dtsg=pkPRc&post_form_id_source=AsyncRequest&__a=1
//Facebook Response
’ÄVÓ¦ÈnJ”ÓòßçÜ"k±DfØ¢^>Õ`Æ™¾/«u]w9w»ªjëüñÿ~üý,«ëª>{d?hÿ߇f½fõÝÙ£³³Žò4Û,êüf›W¥F}µù«Ë¼=ºbÅ&{pvÃî**-Ïý~Öl²:ÍË«*~ˆƒÄ‰mßè‡ÿ^œmóm‘ë‡|]•Öû ?ãµ×uvâõv{óèòáåï_¿Î®Ø"›WÕ—Ù¢Z_>¼©««¼Èf7×7?çËŸ$ÇÿÁ“?mVk0Ù4sÁ?Ýä
£xž}™]ÍËrVfÛˇ;×
/:¶]>Äo%Û4‰œdöùfNu¶®v›Ó¹·uƒ_¼¥<®Wú
×wiõßT÷ä›”-×9*‡ñsÁ6[Aì>µ`e:ÏÒyQ-¾dø*è³<8c
úÖ?f¿mqø§—mgÉ&_•YmákXggo¶5ÛfMÓµO*Ókö%ë^"¨§?!Žè„v„qxB¼*¢ä{ž¯.ò-dmý«*®¤ˆË¦(þ‹¤6[¶Í³ïinŸt“×U“m·Ùl•[#õ×Â]üŽ<Û²‘%š§¬`…õºúšiwï@0¯›¯Œÿû½‹dÄsì**x";ì0ñC!IPâyÂê
×æŸÒ2¥ü‰ÙŽ?ñóT…=èø±sù0HpãäS?r|£t6IÕsè@×—R%ÕÇe™Yïs¨ýQ"eøø 7•ýò|^³rA;Æš¹�ò `ë<öV8õ|×6B*jh'Q9®´r’ „ú&_³¬°ÞT×Ý(Áîù1’é4?¦ã
!»$äЇ%ë4qϹWÈQä&IœH}
Yen has a full page, but I'm short.
It looks like a picture, but I can not open it.
The code for my php page:
The user copy/paste the headers it has captured with wireshark.
PHP Code:
<?php
$headers = strstr($_POST['post_header'],'Host:');
$content = strstr($_POST['post_body'],'edge_type');
parse_str($content, $result);
$data= array();
foreach($result as $key=>$value)
{
$data[$key] = $value;
}
$content = http_build_query( $data);
$options = array( 'http' => array( 'user_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1) Gecko/20061010 Firefox/2.0',
'method' => 'POST',
'content' => $content,
'header' => $headers ) );
$context = stream_context_create( $options );
echo nl2br($headers);echo '
';
echo nl2br($content);
echo '
';
$return = file_get_contents( 'http://www.facebook.com/ajax/social_graph/fetch.php', false, $context );
echo nl2br($return);
?>
Can you help me in retrieving facebook fan page with PHP?
Bookmarks