Get the latest Facebook public posts for user timeline

问题内容:

I want to get the latest public Posts from Facebook user timeline.

I get the latest posts from a page with the below code:

$add_id = 'xxxx';
$app_secret = 'xxxx';
$fb = new FacebookFacebook(['app_id' => 'APP_ID', 'app_secret' => 'APP_SECRET', 'default_graph_version' => 'v2.9', 'default_access_token' => 'APP_ID|APP_SECRET', ]);
$request = $fb->request('GET', '/PAGE_ID/feed?fields=picture,message,id,created_time,full_picture,link');
try {
    $response = $fb->getClient()->sendRequest($request);
}

catch(FacebookExceptionsFacebookResponseException $e) {
    echo 'Graph returned an error: ' . $e->getMessage();
    exit;
}

catch(FacebookExceptionsFacebookSDKException $e) {
    echo 'Facebook SDK returned an error: ' . $e->getMessage();
    exit;
}

$s = $response->getDecodedBody();

how can I get the users timeline instead of page?

问题评论:

    
You will need permission from the user, before your app can read any of their posts.

原文地址:

https://stackoverflow.com/questions/47756089/get-the-latest-facebook-public-posts-for-user-timeline

Add a Comment