用户Facebook墙上的消息发布

时间:2014-10-12 14:24:05

标签: php facebook post using

我想发布用户fb墙上谁登录...我正在使用此代码..它在app管理员墙上工作正常,但未能在其他用户发布... plz help

<?php
  include_once ('facebook-php-sdk-master\src\facebook.php');
  $appId = 'app id'; //Facebook App ID
  $secret = 'app secret'; // Facebook App Secret
  $returnurl = 'localhost/check/index4.php';  //return url (url to script)
  $permissions = 'publish_actions, manage_pages';  //Required facebook permissions
  $fb = new Facebook(array('appId'=>$appId, 'secret'=>$secret));
  $fbuser= $fb->getUser();

if($fbuser){


if(isset($_POST['text']) and $_POST['text']!='' ){
    try{
        $message= array(
            'message'=>$_POST['text']
        );
        $url='/me/feed';
        $result= $fb->api($url,'POST',$message);
        if($result){
            echo "Data posted to facebook Succefull";
        }else
        {
            echo"Not Posted";
        }
    }catch(FacebookApiException $error){
    echo $error->getMessage();
}

}

  `
try{
    /*
    $qry='select page_id, name from page where page_id in (select page_id from page_admin where uid='.$fbuser.' )';
    $page=$fb->api(array('method'=>'fql.query','query'=>$qry));
    if(empty($page)){
        echo "user do not have any page to post";
    }
    else{
        echo "user has page!";
    }
    */
    echo '<form action="" method="post" name="check">';
    echo '<textarea name="text"></textarea>';
    echo '<input type="submit" value="Post"/>';
    echo '</form>';
}catch(FacebookApiException $error){
    echo $error->getMessage();
}

}

`

else {
$loginurl= $fb->getLoginUrl(array('scope'=>$permissions, 'redirect-url'=>$returnurl));
echo '<a href="'.$loginurl.'" >Login with Fb</a>';
}

?>

仅在管理员墙上发送评论

1 个答案:

答案 0 :(得分:0)

来自changelog

  

申请超过public_profile,电子邮件和user_friends权限的应用必须经过Facebook审核,然后才能向用户请求这些权限。

publish_actions和manage_pages需要在Facebook为其他人工作之前通过Facebook审核。未经批准,它们仅适用于在App(Admin / Dev / Tester)中具有角色的用途。有关详细信息,请参阅此页面:https://developers.facebook.com/docs/apps/review/login