0

我想在群墙上发帖。我有“user_groups”和“publish_stream”的权限。还有access_token。

这是我的代码:

                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
    }

当我运行这段代码时,我得到一个返回 id,它是页面 id。但我的群组墙上没有任何帖子。如何解决这个问题?

4

1 回答 1

1

此代码适用于我发布到 Facebook 页面。

  1. 获取 FB 页面访问令牌 ($value['access_token']) 及其页面 id ($value['id'])
  2. 填充 $params 数组
  3. 使用 FB API 发布您的消息 3.

这是一个片段

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 );
}
于 2013-03-12T10:07:36.627 回答