Search code examples
phpfacebookfacebook-page

How to get facebook page id via php?


Suppose i have a facebook page link http://facebook.com/page_name and i am not the admin of the page. Is it possible to find out the facebook id, profile pics of the page and fan count?

Thanks!


Solution

  • FB id and some informations: yes. See Graph API docs.

    edit: Some code to get id from my app:

    $arg = $_REQUEST['arg'];
    if ($arg != ''){
    
            $arg = str_replace(
                    array('http://','www.','facebook.com/','/'),
                    '',
                    $arg
            );
    
            $elseID = file_get_contents('https://graph.facebook.com/?ids='.$arg.'&fields=id');
            $elseID = json_decode($elseID,true);
            $elseID = $elseID[$arg]['id'];
    }