Ad

How To Post Image On Facebook Timeline Using Graph Api 4.0?

- 1 answer

I am creating an API to post on my Facebook timeline using graph API 4.0. For this, i am first creating an album and then post image in that album.

here is the code

$facebook = new Facebook(array(
    'appId'  => 'APP_ID',
    'secret' => 'APP_SECRET',
    'cookie' => true,
));

$user = $facebook->getUser();
if ($user) {

  //Create an album
  $album_details = array(
        'message'=> 'Album desc',
        'name'=> 'Album name'
  );
  $create_album = $facebook->apiRequest('/me/albums/{user-access-token}', 'post', $album_details);

  dd($create_album);

}

which returns an error

Raw Provider API response: {\"error\":{\"message\":\" This object does not exist or does not support this action\"

But when i gave page token instead of a user access token , it works fine. I am new to this. So, i have no idea how to solve this.

Ad

Answer

The Facebook API no longer permits publishing to personal profile feeds.

https://developers.facebook.com/docs/graph-api/reference/v4.0/user/feed#publish

As of April 24,2018, the publish_actions permission has been removed. Please see the Breaking Changes Changelog for more details. To provide a way for your app users to share content to Facebook, we encourage you to use our Sharing products instead.

Ad
source: stackoverflow.com
Ad