简体   繁体   中英

How to post to a facebook group wall in offline mode using graph API? (I am a member of group)

I am trying to post a status update on the wall of a group which I am a member of. Here is the code I am using

            <?php
            require 'facebook-php-sdk/src/facebook.php';    
            $appId = 'xxxxxxxxxxxxxxxx';    
            $appSecret = 'xxxxxxxxxxxxxxxx';    
            $extended_access_token = 'xxxxxxxxxxxxxxxxxxxxx';

            $facebook = new Facebook(array('appId' => $appId, 'secret' => $appSecret)); 

            $msg_body = array(
                'message' => 'Good evening',
                'type' => 'status',
                'access_token' => $extended_access_token,
            );

            $groups = array(
                            'Group name' => '1234567',
                        );
            foreach($groups as $group_name => $group_id){
                try {
                    $post_url = "/$id/feed";
                    $postResult = $facebook->api($post_url, 'post', $msg_body );
                    print_r($postResult);
                } catch (FacebookApiException $e) {
                    echo $e;
                }   
            }
            ?>

If I login to fb via browser and hit this page in a new tab, the message is getting posted to the group wall. But If I am not logged into facebook, then if I hit this page, no message is getting posted and I am getting an error message

OAuthException: (#200) The user hasn't authorized the application to perform this action

How can I post to this group via offline mode? Searched a lot for this, could not find any useful info.

您需要拥有组所有者的权限

$id更改$id $group_id即可。

您已准备好让应用获得这种渗透:publish_actions,publish_stream,user_groups,

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