简体   繁体   中英

How to post on group wall of facebook

I want to post on group wall. I have permission of "user_groups" and "publish_stream". and also access_token.

and here is my code:

                try{
            $statusUpdate = $this->facebook->api('/'.$group_id.'/feed', 'post',
                 array(
                'name' => stripslashes($productname),
                //'caption'=>$caption,
                'message' => $message,
                'description' => $description,
                'picture' => $picture,
                'link'=>$link));

                    $postid =  $statusUpdate['id']; // return id


            } catch (Exception $e){
                        $postid = 0;
                    }
                    return $postid; // return id
    }

When I run this code I get a return id which was the page id. but nothing post on my group wall. how to solve this?

This code works for me to post to a facebook page.

  1. Get FB page access token ($value['access_token']) and its page id ($value['id'])
  2. Populate the $params array
  3. use the FB API to post your message 3.

This is a snippet

foreach ($pages as $key => $value) {
   $params = array(
      'access_token' => $value['access_token'],
       'message' => $message
    );
    // ask facebook api to post the message to the selected page
    $facebook->api()->api( "/" . $value['id'] . "/feed", 'POST', $params );
}

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