Facebook post on page with PHP SDK

后端 未结 2 867
囚心锁ツ
囚心锁ツ 2021-01-02 23:06

I\'d like to post on page - throught my site. . I didn\'t find anything that could help me in documentation. Also none of google results gave mi answer.

func         


        
2条回答
  •  北海茫月
    2021-01-02 23:26

    If I understand this correctly, you want to send a message to the user's wall who's connected to your application via your website the moment they log in? If so, try this. Rework the script to prevent constant posting, but this model, in theory, should work.

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

    // Place messaging portion here instead.

        $message = $facebook->api('/me/feed', 'post', array(
                                                                 'message'=> '', 
                                                                 'picture' => '', 
                                                                 'link'=> '',
                                                                 'description'=>'Description', 
                                                                 'name'=> '', 
                                                                 'privacy'=> '',
                                                                 'caption'=> '',                                                           
    
                                                                 )
                                       );
    
                } catch (FacebookApiException $e) {
                    error_log($e);
                }
    

    So if the user is connected with your application and the session is valid, it will automatically send the post to their news feed (Wall).

提交回复
热议问题