Search code examples
facebookfacebook-graph-apifacebook-php-sdkfacebook-apps

Access non-friends profile updates using php


Is it possible to access profile updates of a facebook user who is not in your(application authorizer) friend list or like-list?

For example: http://www.facebook.com/zuck or http://www.facebook.com/mashable

Is it possible using facebook api?


Solution

  • <?php
        require 'src/facebook.php';
        $facebook = new Facebook(array(
          'appId'  => 'xxx',
          'secret' => 'xxx',
        ));
        $username = isset($_GET['username'])?$_GET['username']:"johnbevere.page";
        $profile = $facebook->api('/'.$username.'/posts');
    ?>
    
    <br/><br/><img src="https://graph.facebook.com/<?=$username?>/picture">
    
    <?php
        foreach( $profile['data'] as $data ){
            if($data['message']){
                echo $data['message']."<br><hr><br>";
            }else{
                echo $data['story']."<br><hr><br>";
            }
        }
    ?>
    

    Success:

    1. Page updates
    2. User timeline Activity Log

    Failed:

    1. User timeline Feed

    It is not possible to scrap the public feed of random profile using facebook API