在此页面的墙壁上发布消息(不是管理员) [英] Post a message to the wall of a page as this page (not the admin)
问题描述
我想发布到一个名为XY的页面,它应该直接显示在页面上,而不是从另一个用户(管理员)发布。这是我从 http: //qscripts.blogspot.de/2011/02/post-to-your-own-facebook-account-from.html ,但是这个帖子到其他用户不到主页面的区域。如果我将页面ID号替换为我,它将发布到管理员页面,并正确到主要区域。
I want to post to a page named XY and it should appear on the page directly and not as a posting from another user (the admin). This is the code I adapted from http://qscripts.blogspot.de/2011/02/post-to-your-own-facebook-account-from.html but this posts to the area for other users not to the main page. If I replace the page-id number by "me" it posts to admins page and correctly to the main area.
#!/usr/bin/perl -I/opt/ActivePerl-5.16/site/lib/
# http://qscripts.blogspot.de/2011/02/post-to-your-own-facebook-account-from.html
use strict;
use warnings;
use open qw(:std :utf8);
use LWP::Simple;
use YAML;
use JSON;
use URI;
use utf8;
my $access_token = 'top secret';
graph_api('1484559088426611/feed', {
access_token => $access_token,
message => 'Hello World! I’m posting Facebook updates from a script!',
description => 'You want to create a script to read messages and post status updates to your own '
. 'Facebook account, but you find the official documentation confusing and '
. 'you aren’t sure where to start. Search no more because here you’ll find '
. 'the easiest way to do just this.',
method => 'post'
});
exit 0;
sub graph_api {
my $uri = new URI('https://graph.facebook.com/' . shift);
$uri->query_form(shift);
my $resp = get("$uri");
return defined $resp ? decode_json($resp) : undef;
}
推荐答案
如果您使用用户/管理员的访问令牌,则该帖子将以用户/管理员身份发布,但不会作为页面本身发布。
While posting on a page, if you use the access token of a user/admin the post will be published as the user/admin but not as a page itself.
要在页面上发布为页面本身,您应该使用 页面访问令牌 。要获取页面访问令牌,您需要权限 manage_pages
,您可以致电 / {user-id} / accounts
。这样你就可以获得你的页面的访问令牌。
To post on a page as a page itself you should use the page access token. To get a page access token you need the permission manage_pages
and you can make a call to /{user-id}/accounts
. This way you will get the access token for your page.
现在好的是,你可以有一个页面访问令牌,永不过期 !我已解释步骤: https://stackoverflow.com/a/18322405/1343690
Now the good thing is that you can have a page access token that never expires! I've explained with steps here: https://stackoverflow.com/a/18322405/1343690
希望有帮助。祝你好运!
Hope it helps. Good luck!
这篇关于在此页面的墙壁上发布消息(不是管理员)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!