任何人都可以告诉我如何使用php sdk这样做。
我使用了这段代码。此代码假设发布到用户的时间轴以及粉丝页面。登录的人将是正在发帖的人。所以在粉丝页面上 这可能会出现在最近的活动中。但是,现在代码已经停止工作,说用户没有授权应用程序。我不明白为什么会发生这种情况。
include("../php-sdk/facebook.php");
/*START FACEBOOK lOGIN*/
$facebook = new Facebook(array(
'appId' => Appid,
'secret' => Appsecret,
'cookie' => true
));
$pageId = PageId;
$user= $facebook->getUser();
$newfbuser = 0;
if (!empty($user)) {
$uid = $facebook->getUser();
// $fb_access_token = $facebook->getAccessToken();
$url = $facebook->getLoginUrl(array(
'req_perms' => 'email,status_update,publish_stream, manage_pages'
));
$user = $facebook->api('/me');
$fb_access_token = $facebook->getAccessToken();
$param = array(
'method' => 'users.getInfo',
'uids' => $uid,
'fields' => array('name','sex')
);
$users_getinfo = $facebook->api($param);
$save['oauth_uid'] = $users_getinfo['0']['uid'];
$save['oauth_provider'] = 'facebook';
$save['facebook_email'] = $users_getinfo['0']['email'];
$save['name'] = $users_getinfo['0']['name'];
$link_url = "http://google.com";
$pic = 'http://xxxxx/images/Testing.jpg';
$attachment = array(
'access_token' =>$fb_access_token,
'message' => 'This is a message by bob',
'link' => 'http://xxxxx/');
// print_r($fb_access_token);
echo 'on my timeline<br />';
$facebook->api("/me/feed",'post',$attachment);
$facebook->api("/$pageId/feed",'post',$attachment);
echo 'successfully posted';
}
答案 0 :(得分:1)
// $ fb_access_token = $ facebook-&gt; getAccessToken(); $ url = $ facebook-&gt; getLoginUrl(array( 'req_perms'=&gt; 'email,status_update,publish_stream,manage' ));
没有这样称呼“管理”,正确的权限是 manage_pages