doulao1966
2011-10-24 12:19
浏览 41
已采纳

Facebook php app,req_perms

I am trying to make a small facebook application with php & facebook PHP API. I need to give a permissions to post status, etc. But it is doesn't work. Here is my code:

<?php
require './src/facebook.php';
$facebook = new Facebook(array(
  'appId'  => '###',
  'secret' => '###',
));

$user = $facebook->getUser();

if ($user) {
if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
  echo "<a href='$logoutUrl'>Logout</a>";
} else {
  $loginUrl = $facebook->getLoginUrl(array(
       'req_perms' => 'publish_stream,read_friendlists,email'   
  ));
  echo "<a href='$loginUrl'>Login with Facebook</a>";
}

?>

When i click on Login url do not get permissions (publish_stream,read_friendlists,email). I see only "Logging in will not add this app's activity to Facebook."

图片转代码服务由CSDN问答提供 功能建议

我正在尝试使用php&amp; facebook PHP API。 我需要授予发布状态等权限。但它不起作用。 这是我的代码:

 &lt;?php 
require'./src/facebook.php';
$facebook = new Facebook(array(
'appId')  =&gt;'###',
'secret'=&gt;'###',
)); 
 
 $ user = $ facebook-&gt; getUser(); 
 
if($  user){
if($ user){
 $ logoutUrl = $ facebook-&gt; getLogoutUrl(); 
 echo“&lt; a href ='$ logoutUrl'&gt; Logout&lt; / a&gt;”; 
} else  {
 $ loginUrl = $ facebook-&gt; getLoginUrl(array(
'req_perms'=&gt;'publish_stream,read_friendlists,email'
)); 
 echo“&lt; a href ='$ loginUrl'&gt; 使用Facebook登录&lt; / a&gt;“; 
} 
 
?&gt; 
   
 
 

当我点击登录时,网址不会获得权限(publish_stream,read_friendlists ,电子邮件)。 我只看到“登录将不会将此应用程序的活动添加到Facebook。”

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanbohan2015 2011-10-24 12:42
    已采纳

    First, You've got syntax error in your code. Watch these 2 lines

    if ($user) {
    if ($user) {
    

    delete one of them.

    Second, Do not use req_perms, but scope, which is point of your problem

    This one works pretty fine

    <?php 
    require './src/facebook.php';
    $facebook = new Facebook(array( 
      'appId'  => '##', 
      'secret' => '##', 
    )); 
    
    $user = $facebook->getUser(); 
    if ($user) { 
        $logoutUrl = $facebook->getLogoutUrl(); 
        echo "<a href='$logoutUrl'>Logout</a>"; 
    } else { 
        $loginUrl = $facebook->getLoginUrl(array( 
          'scope' => 'publish_stream,read_friendlists,email'    
      )); 
      echo "<a href='$loginUrl'>Login with Facebook</a>"; 
    }
    

    demo (No, I'm not collecting any data)

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题