使用 Graph API 发布到 Facebook 页面 - 返回 ID 但不显示
我正在尝试使用 Facebook C# SDK 发布到 Facebook 页面流,但失败得很惨。这就是我的代码的样子:
var app = new Facebook.FacebookApp(_accessToken);
var parameters = new Dictionary<string, object>
{
{ "message" , promotionInfo.TagLine },
{ "name" , promotionInfo.Title },
{ "description" , promotionInfo.Description },
{ "picture" , promotionInfo.ImageUrl.ToString() },
{ "caption" , promotionInfo.TargetUrl.Host },
{ "link" , promotionInfo.TargetUrl.ToString() },
{ "type" , "link" }
};
var response = app.Post(_targetId + "/feed", parameters);
我已经检查过,可以看到 Fiddler 中的请求传递到 Facebook,并且我得到了一个 ID - 但是,当我尝试在 http://graph 上查看该 ID 时.facebook.com/[parentid]_[postid]
我只得到一个带有“false”的页面,并且该帖子也不会出现在 Facebook 页面本身上。如果我只是输入一个不存在的随机 postid,我会得到“您请求的某些别名不存在”。
accessToken被授权使用publish_stream和离线访问(使用 此网址)
有什么想法可能会出现问题吗?谢谢
更新我应该补充一点,如果我将 _targetId 更改为“我”(即直接发布到我自己的个人资料页面),则效果很好
I'm trying to use the Facebook C# SDK to post to a Facebook page stream, but I'm failing miserably. This is what my code looks like:
var app = new Facebook.FacebookApp(_accessToken);
var parameters = new Dictionary<string, object>
{
{ "message" , promotionInfo.TagLine },
{ "name" , promotionInfo.Title },
{ "description" , promotionInfo.Description },
{ "picture" , promotionInfo.ImageUrl.ToString() },
{ "caption" , promotionInfo.TargetUrl.Host },
{ "link" , promotionInfo.TargetUrl.ToString() },
{ "type" , "link" }
};
var response = app.Post(_targetId + "/feed", parameters);
I've checked and I can see the request in Fiddler go through to Facebook, and I get an ID back - however, when I try and view that ID at http://graph.facebook.com/[parentid]_[postid]
I just get a page with "false" on it, and the post doesn't appear on the Facebook page itself either. If I just enter a random postid that doesn't exist, I get "Some of the aliases you requested do not exist" instead.
The accessToken is authorised to use publish_stream and offline access (generated using this url)
Any ideas what could be going wrong? Thanks
Update I should add, this works fine if I change the _targetId to "me" (ie posting directly to my own profile page)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在这里找到了解决方案: Facebook 的哪些权限允许发布到页面墙(不是个人资料墙)? 哪个做到了这一点
I found the solution here: Which Facebook permissions allow for posting to a page wall (not profile wall)? which did the trick
这只是一个想法,但是在获得read_stream扩展权限后尝试一下。
我从经验中知道,您可以使用返回的 ID 来删除帖子,但如果没有 read_stream,我认为您无法检索它(以及更有趣的内容,例如评论)
This is just an idea, but try it after obtaining the read_stream extended permission.
I know from experience that you can use the ID returned to delete the post, but without read_stream I don't think you can retrieve it (and more interesting stuff like the comments)
要发布到 Facebook 页面,您需要请求管理页面权限。
您还必须使用页面 access_token 而不是用户 access_token。
To post to a Facebook page, You need to request manage_pages permission.
also you have to use the PAGE access_token not User access_token.