简体   繁体   中英

unable to upload a photo to a facebook page timeline using php sdk

I have a PHP app which interacts with facebook. I'm successfully able to post a photo to user wall , uswer timeline and to the wall of a facebook page, but when i try to post the same photo to facebook page timeline it throws an error " invalid appsecret_proof parameter ". i commented out the code that tries to set the appsecret_proof in base_facebook.php file and then tried running the app it gave " The user hasn't authorized the application to perform this action " error. i have given 'photo_upload , publish_stream , publish_actions , manage_pages , user_photos' permissions to the app . i have set the access token of the page before making the following call

$ret_obj = $facebook->api ( '/page_id/feed' , 'POST' , array(  
                                                'source'  => $photo ,
                                                'message' => $message ,
                                                'name' => 'vinay' ,
        ) );

how do i resolve this?

edit : i have also disabled the "Require AppSecret Proof for Server API calls" in the app advanced settings

If you want to post to a specific album, use /album_id/photos and if you don't care of any album simply use: /page_id/photos .

Now, if you use the user access token , the photo will be uploaded on that page (in either of the above two cases), but it will appear in the page wall under the section:

Recent Posts by Others on PageName

If you want your photo to be visible on the page's timeline; the photo must be published on behalf of the page itself- using the page access token , not the user access token.

To get the page access token query for: /me/accounts with permission: manage_pages . Demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM