I want to include the FB Page wall into the website. For that purpose I need the access token, but on the FB I'm one of the admins not the owner.
When I request an access token I get one of my profile not the profile that I´m administrating. Can I get a token for that wall as admin and not owner ?
如果您查看http://developers.facebook.com/docs/authentication/ ,则可以看到有一些以应用程序或页面身份登录的选项:这些选项应该可以为您提供所需的访问令牌。
From: http://developers.facebook.com/docs/reference/api/permissions/
"Page access_token
An access_token used to manage a page. This is used when you want to perform an operation acting as a Page. This access token is retrieved by issuing an HTTP GET to /USER_ID/accounts or to /PAGE_ID?fields=access_token with the manage_pages permission. Getting /USER_ID/accounts will return a list of Pages (including app profile pages) to which the user has administrative access in addition to an access_token for each Page. NOTE: After September 22, 2011, manage_pages permission will be required for all access to a user's pages via this connection, ie for both reading the user's pages and also retrieving access_tokens for those pages. See the documentation for the User object for more information."
Facebook has extended their page
object to make it easier to retrieve a "page" `access_token", what you need is:
PS: I'm using the PHP-SDK
<?php
// This code is just a snippet of the example.php script
// from the PHP-SDK <http://github.com/facebook/php-sdk/blob/master/examples/example.php>
require '../src/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => 'app_id',
'secret' => 'app_secret',
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
$page_id = 'page_id';
$page_info = $facebook->api("/$page_id?fields=access_token");
if( !empty($page_info['access_token']) ) {
$args = array(
'access_token' => $page_info['access_token']
);
$page_posts = $facebook->api("/$page_id/posts","get",$args);
}
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// Login or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl(array('scope'=>'manage_pages,read_stream'));
}
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.