简体   繁体   English

Facebook getloginurl其他权限

[英]Facebook getloginurl additional permissions

I just try to update to PHP SDK 4.0. 我只是尝试更新到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: 我将所有文件复制到文件夹“ ./facebook4”,并实现了以下代码:

// 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. 调用页面时显示Test1,但不显示Test2和“此处链接”。 So I guess there must be a problem with getLoginUrl but I have no idea what it is 所以我想getLoginUrl一定有问题,但我不知道它是什么

https://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/ 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. 不确定要使用“ user_actions:criminalcase”实现什么,没有这样的许可。 Also, you don´t need all those require statements when using the autoloader. 另外,在使用自动加载器时,您不需要所有这些require语句。

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): 重要提示:您很可能不会获得read_stream批准,因此它仅对在您的应用中具有角色的用户有效(管理员/开发人员/测试人员):

This permission is granted to apps building a Facebook-branded client on platforms where Facebook is not already available. 此权限授予在尚不可用Facebook的平台上构建Facebook品牌客户端的应用程序。 For example, Android and iOS apps will not be approved for this permission. 例如,Android和iOS应用程序将不会获得此权限。 In addition, Web, Desktop and TV apps will not be granted this permission. 此外,不会向Web,桌面和电视应用授予此权限。

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

There is still problem in your syntax. 您的语法仍然存在问题。

try this 尝试这个

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

I am not sure about your "user_actions:criminalcase" permission. 我不确定您的“ user_actions:criminalcase”权限。

But I have corrected here the syntax. 但我在这里更正了语法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM