简体   繁体   English

如何在Facebook的小组墙上张贴

[英]How to post on group wall of facebook

I want to post on group wall. 我想在组墙上发布。 I have permission of "user_groups" and "publish_stream". 我具有“ user_groups”和“ publish_stream”的权限。 and also access_token. 以及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. 当我运行此代码时,我得到一个返回ID,即页面ID。 but nothing post on my group wall. 但是在我的小组墙上没有任何内容。 how to solve this? 如何解决呢?

This code works for me to post to a facebook page. 此代码对我有用,可以发布到Facebook页面。

  1. Get FB page access token ($value['access_token']) and its page id ($value['id']) 获取FB页面访问令牌($ value ['access_token'])及其页面ID($ value ['id'])
  2. Populate the $params array 填充$ params数组
  3. use the FB API to post your message 3. 使用FB API发布您的消息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 );
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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