Search code examples
laravelfacebook-graph-apifacebook-php-sdk

unable post to facebook user's wall by laravel


I'm using FaceBook SDk with laraveland try to post to user's in test roles list and I have his access_token and this token has Scopes email, manage_pages, pages_show_list, publish_pages, publish_to_groups, public_profile

but every time I try to post I got that message

(#200) If posting to a group, requires app being installed in the group, and \ either publish_to_groups permission with user token, or both manage_pages \ and publish_pages permission with page token; If posting to a page, \ requires both manage_pages and publish_pages as an admin with \ sufficient administrative permission

my controller code is

protected $fpApi;

public function __construct(FaceBook $facebook)
{
    $this->middleware(function($request,$next) use($facebook){
        $facebook->setDefaultAccessToken('WucllFJglb ..... Token from db');
        $this->fpApi = $facebook;
        return $next($request);
    });
}




public function retrieveUserProfile(){

    try{
        $attempt = $this->fpApi->post('/me/feed',['message'=>'try post a post'])->getGraphNode()->asArray();
        if($attempt['id']){ dd('done');}
    }catch(\FacebookSDKException $e)
    {
        dd($e);
    }

}

Solution

  • Posting to the user wall is not possible anymore. The neccessary permission (publish_actions) is deprecated.

    Changelog: https://developers.facebook.com/docs/graph-api/changelog/breaking-changes/#4-24-2018