Auto post stream (feed) to app users

别来无恙 提交于 2019-12-22 01:30:40

问题


How can i post stream ($facebook->api('/me/feed', 'post', $attachment);) to my app users on anytime. I think i can get access token via $facebook->getAccessToken(); but after, how can i post to wall?


回答1:


Grant the publish_stream permission and use the user id after that instead of me:

$facebook->api("/$user_id/feed", 'post', $attachment);

For more information, check the last edit (EDIT 4) on this answer (also follow the discussion on the other answer that I linked to there).




回答2:


First: See if the session is valid

if ($session) {
    try {
     $uid = $facebook->getUser();
    $me = $facebook->api('/me');

Second - IF it is valid, you will make the API call to post

       $facebook->api('/me/feed', 'post', array(
    'message'=> 'Sample Message', 
    'picture' => 'URL of Picture', 
    'link'=> 'URL',
    'description'=>'Description',
    'name'=> 'Name of Post',
    'privacy'=> 'privacy',
    'caption'=>'Caption',                                                                ) );
 } catch (FacebookApiException $e) {
        error_log($e);
      }
    }

It's simple, just copy all the code you see above, it should work out the box.



来源:https://stackoverflow.com/questions/4945838/auto-post-stream-feed-to-app-users

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!