donglao4370 2014-12-19 22:23
浏览 270

Facebook获得了额外的权限

I just try to update to PHP SDK 4.0. I can't find my mistake and hope you can help me. I copied all files to the folder "./facebook4" and implemented following code:

// Skip these two lines if you're using Composer
define('FACEBOOK_SDK_V4_SRC_DIR', '/./facebook4/src/Facebook/');

// if you include this file you don't need to use composer
require __DIR__ . '/./facebook4/autoload.php';

// include required files form Facebook SDK
require_once( './facebook4/HttpClients/FacebookHttpable.php' );
require_once( './facebook4/HttpClients/FacebookCurl.php' );
require_once( './facebook4/HttpClients/FacebookCurlHttpClient.php' );
require_once( './facebook4/Entities/AccessToken.php' );
require_once( './facebook4/Entities/SignedRequest.php' );
require_once( './facebook4/FacebookSession.php' );
require_once( './facebook4/FacebookRedirectLoginHelper.php' );
require_once( './facebook4/FacebookRequest.php' );
require_once( './facebook4/FacebookResponse.php' );
require_once( './facebook4/FacebookSDKException.php' );
require_once( './facebook4/FacebookRequestException.php' );
require_once( './facebook4/FacebookOtherException.php' );
require_once( './facebook4/FacebookAuthorizationException.php' );
require_once( './facebook4/GraphObject.php' );
require_once( './facebook4/GraphSessionInfo.php' );

use Facebook\HttpClients\FacebookHttpable;
use Facebook\HttpClients\FacebookCurl;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\Entities\AccessToken;
use Facebook\Entities\SignedRequest;
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookOtherException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\GraphSessionInfo;

    FacebookSession::setDefaultApplication('AppID','secretAppID');

$redirect_url = "http://www.mypage.de/Logged.php";

// use the helper 
$facebook = new FacebookRedirectLoginHelper($redirect_url);
// get a loginurl


$permissions = array(
'email',        
'read_stream',
'user_actions:criminalcase'
); 

echo "Test1";
$loginUrl = $facebook->getLoginUrl($permissions);
echo "Test2";

echo "<a href='".$loginUrl."'>Link here</a>";

Test1 is displayed when I call the page but Test2 and the "Link here" are not displayed. So I guess there must be a problem with getLoginUrl but I have no idea what it is

  • 写回答

2条回答 默认 最新

  • doumu9799 2014-12-20 10:15
    关注

    https://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/

    Take a closer look at the array:

    $params = array(
      'scope' => 'read_stream, friends_likes',
      'redirect_uri' => 'https://www.myapp.com/post_login_page'
    );
    

    So in your case, it should be like this:

    $permissions = array(
        'scope' => 'email, read_stream, user_actions:criminalcase'
    );
    

    Not sure what you want to achieve with "user_actions:criminalcase", there is no such permission. Also, you don´t need all those require statements when using the autoloader.

    Important: You will most likely not get read_stream approved, so it will only ever work for users with a role in your App (Admin/Developer/Tester):

    This permission is granted to apps building a Facebook-branded client on platforms where Facebook is not already available. For example, Android and iOS apps will not be approved for this permission. In addition, Web, Desktop and TV apps will not be granted this permission.

    Source: https://developers.facebook.com/docs/facebook-login/permissions/v2.2#reference-read_stream

    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题