从该页面更新Facebook页面状态 [英] Update facebook page status from that page itself

查看:113
本文介绍了从该页面更新Facebook页面状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更新我的页面的状态(从我的页面)。我已经使用以下代码成功发布到页面的墙壁:

I'm trying to update the status of my page (from my page). I have been successful in posting to the wall of the page with the following code:

require_once 'facebook-php-sdk/src/facebook.php';

// Create our Application instance.
$facebook = new Facebook(array(
  'appId'  => '...',
  'secret' => '...'
));

$attachment = array(
'access_token' => "...",
'message'=> "Hello World"
);

$facebook->api('/pageId/feed','POST', $attachment);

但是,该帖子显示我从我的帐户(即:Joe博客)发布到我的网页想要它显示它是由页面本身发布的(即:页面名称)。

But the post shows that I posted to the page from my account(ie: Joe Blogs) where I want it to show that it was posted by the page itself (ie: Page Name).

或者我会错误的吗?我应该尝试更改页面的状态(如果可能)?

Or am I going about it the wrong way? Should I be trying to change the Status of the page (if possible)?

任何帮助将不胜感激。

推荐答案

经过这几天拉我的头发,我似乎已经解决了这个问题。我会解释:

After many days of pulling my hair out over this one I have seemed to have solved this issue. I will explain:

我的帖子来自我自己而不是页面的原因是因为我使用的access_token来自我的帐户,而不是从页面。您将需要从页面本身获取访问令牌。

The reason that my posts were coming from myself instead of the page is because the access_token I was using was from my account instead of from the page. You will need to get an access token from the page itself.

下面介绍这一点(http://developers.facebook.com/docs/api#auth) 网页模拟

Which is explained here (http://developers.facebook.com/docs/api#auth) under 'Page impersonation'

这是我这样做的。

我首先让我的帐户权限管理使用此网址的页面:

I firstly gave my account permission to manage the pages I had by using this url:

https://graph.facebook.com/oauth/authorize?client_id=...&redirect_uri=...&scope=manage_pages

您将需要将应用程序ID并插入一个重定向网址 - 你会被带到一个页面,女巫会要求你授权(你应该说是:)

you will need to insert client_id with your app id and insert a redirect url - You'll be brought to a page witch will ask you to authorise (which you should say yes to :)

然后在php我访问我现有帐户的详细信息以及我使用以下代码管理的页面:

then in php I accessed details of my current account and the pages I administer with the following code:

require_once 'facebook-php-sdk/src/facebook.php';

$facebook = new Facebook(array(
  'appId'  => '...',
  'secret' => '...'
));

$attachment2 = array(
'access_token' => "..." //this is my current user access_token
);

$page =  $facebook->api('/me/accounts', 'get', $attachment2);
print_r($page);

这将打印出您管理的页面和access_tokens的这些页面的详细信息(bingo!)

This will print out details about the pages you administer and access_tokens for those pages (bingo!)

然后你可以把那个/这些access_token插入到我上面发布的代码中,并且它会从你的页面发贴到你的页面。 :)

you can then take that/those access_token(s) and insert it in the code that I published above and whala - it will post to your page from your page. :)

这篇关于从该页面更新Facebook页面状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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