Facebook PHP SDK 5.0-发布到组 [英] Facebook PHP SDK 5.0 - Posting to group

查看:73
本文介绍了Facebook PHP SDK 5.0-发布到组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经被困了一段时间了.我正在尝试为自己编写一个小应用程序,以自动发布到FB成员中的多个组.我是PHP的新手,但这是我在FB允许的访问能力方面最强的技能.到目前为止,我可以毫无问题地张贴到自己的墙上,但是一旦我尝试将其张贴到自己的FB测试小组,我就很困惑.到目前为止,这是我的代码...

I have been stumped for a while now. I'm attempting to write myself a small app to automatically post to a number of groups that I am members of in FB. I'm a PHP novice, but this is about my strongest skill set for what FB allows in terms of access that I can tell. So far, I CAN post to my own wall no problem but once I try and post to my own FB testing group I'm stumped. Here is my code so far...

<?php
require_once __DIR__ . '/vendor/autoload.php';    
require 'src/config.php';
require 'src/facebook.php';

$fb = new Facebook\Facebook([
  'app_id' => $config['App_ID'],
  'app_secret' => $config['App_Secret'],
  'default_graph_version' => 'v2.8',
  ]);

$linkData = [
  'link' => 'http://www.example.com',
  'message' => 'Test post to my feed.',
  ];

try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->post('/{group_id}/feed', $linkData, $config['Access_Token']);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
?>

当前生成的错误是:Graph返回了一个错误:(#200)权限不足,无法代表查看者发布目标

Currently the error that this is generating is: Graph returned an error: (#200) Insufficient permission to post to target on behalf of the viewer

我已将应用程序公开,并使用manage_pages和publish_pages生成了访问令牌.不幸的是,到目前为止我还没有想法.任何帮助将不胜感激.预先感谢.

I have made the app Public and generated the access token with manage_pages and publish_pages. Unfortunately I'm out of ideas as of this point. Any help would be greatly appreciated. Thanks in advance.

推荐答案

确定.我现在已经解决了我的问题.那是我必须在FB用户帐户中进入应用程序设置",然后将我的应用程序从仅我"更改为公开".完成后,我就可以发布到我的论坛了.接下来将要弄清楚如何在"Sell Something"类型的帖子的适当字段中发布,然后在我不是管理员的组中对其进行测试.

OK. I figured out my problem at this point. It was that I had to go into the App Settings in my FB user account and change my App from "Only Me" to Public. Once I did that I was able to post to my groups. Next will be to figure out how to post into the proper fields for a "Sell Something" type of post and then to test it in groups that I'm not an admin of.

我认为必须发布到非管理员组中,因为那里有很多服务可以自动发布FB,而且他们必须以某种方式解决它.

I figure it has to be possible to post into non-admin groups since there are a number of services out there for FB auto-posting and they have to get around it somehow.

这篇关于Facebook PHP SDK 5.0-发布到组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆