我使用PHP Facebook SDK构建了一个应用程序。它允许用户使用facebook OAth验证我的应用程序,以便他们可以通过我的应用程序更新其状态。这很好用,但是我的很多用户都有商业页面,他们希望更新商业页面上的状态而不是主要的个人订阅源。这怎么可能?以下是我到目前为止的情况。
if ($status != ''){
try {
$parameters = array(
'message' => "$status"/*,
'picture' => $_POST['picture'],
'link' => $_POST['link'],
'name' => $_POST['name'],
'caption' => $_POST['caption'],
'description' => $_POST['description']*/
);
//add the access token to it
$parameters['access_token'] = $access_token;
//build and call our Graph API request
$newpost = $facebook->api(
'/me/feed',
'POST',
$parameters
);
$success['status'] = "$xml->status";
$xml2 = new XMLGenerator($success, 'facebook','status');
$returnData = $xml2->output;
$returnData = APIResponse::successResponse('200', "$xml->status");
} catch (Exception $e) {
$returnData = APIResponse::errorResponse('400', 'Facebook Error: '.$e);
}
我想我必须改变'/ me / feed'?但到了什么?他们有多个页面,我的应用程序将如何知道要发布到哪个页面?
非常感谢任何帮助。
答案 0 :(得分:0)
您可以将me
替换为PAGE_ID
以发布到页面,例如/ 013857894 / feed。确保您已使用manage_pages
和publish_stream
权限完成了OAuth流程。您可以通过以下链接了解更多信息:
https://developers.facebook.com/docs/reference/api/page/#statuses
如果用户有多个页面,那么您首先需要为他们提供一些选择要发布到哪个页面的方法。您可以通过为该用户调用/me/accounts
来找出给定用户是哪个Facebook页面的管理员。您可以在本页的“连接”部分找到有关此方法的更多信息: