facebook give default page source when i fetched it with php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mayanktalwar1988
Forum Contributor
Posts: 133
Joined: Wed Jul 08, 2009 2:44 am

facebook give default page source when i fetched it with php

Post by mayanktalwar1988 »

when ever i try to read facebook page source they give some default page source

the title of default page stATES Incompatible Browser | Facebook..but the original title of index page is welcome to facebooK

the code used by me is this

Code: Select all

<?php
$url = "http://www.facebook.com";
$str = file_get_contents($url);

echo '<pre>';
echo htmlentities($str); 
?>
its seems like facebok is blocking this type of interaction..if that is the case then is there any other way to get facebook page source out .......because i have treid it on other site
and it works ok for it
Last edited by mayanktalwar1988 on Tue Apr 27, 2010 7:29 am, edited 1 time in total.
phu
Forum Commoner
Posts: 61
Joined: Tue Mar 30, 2010 6:18 pm

Re: facebook give default page source when i fetched it with

Post by phu »

Facebook has always had an API for this sort of thing. They just released a new version that's extremely simple to interact with:
Facebook OpenGraph API
Facebook PHP SDK on github
Post Reply