简体   繁体   English

如何使用facebook-> getLoginStatusUrl()?

[英]How do I use facebook->getLoginStatusUrl()?

I currently redirect the user to the url given and it returns the user back to the web page with 2 get arguments: 'session' and 'perms'. 我目前将用户重定向到给定的url,它使用2个get参数将用户返回到网页:“ session”和“ perms”。

The meaning of perms is obvious. 烫发的含义很明显。

Session appears to be a JSON slash escaped array. 会话似乎是JSON斜杠转义的数组。 After json_decode(slashcstrip($_GET['session'])) i find the following members: uid,session_key,secret,expires,base_domain,access_token, sig. 在json_decode(slashcstrip($ _ GET ['session']))之后,我找到以下成员:uid,session_key,secret,expires,base_domain,access_token,sig。 What are secret and sig? 什么是秘密和信号? How do I use them to validate the data? 如何使用它们来验证数据?

Thanks! 谢谢!

The sdk validates the data for you using that session information. sdk使用该会话信息为您验证数据。 All you need to do is call $facebook->getUser() and check that you get back a user id. 您需要做的就是调用$ facebook-> getUser()并检查您是否获得了用户ID。

$next_url = $facebook->getLoginStatusUrl($params); $ next_url = $ facebook-> getLoginStatusUrl($ params); retrieve fb user Login Status 检索fb用户登录状态

From what I understand the status URL is used to determined the status of a user. 据我了解, 状态URL用于确定用户的状态。 If you do an HTTP call to the the generated status URL facebook will redirect to one of the redirect urls based on the user status, you can use the request of the URL to update the user session on your application and take a handling action for the state of the user 如果您对生成的状态URL进行HTTP调用,facebook将根据用户状态重定向到其中一个重定向URL,则可以使用URL请求来更新应用程序上的用户会话,并为该应用采取处理措施。用户状态

ok_session => user has facebook session -> start app
no_user    => unknown user, ask user to login
no_session => known user, ask to login

Follow these steps: 跟着这些步骤:

  1. You generate an url: $next_url = $facebook->getLoginStatusUrl(); 您生成一个URL:$ next_url = $ facebook-> getLoginStatusUrl();
  2. redirect the user to this url: header('Location: '.$next_url); 将用户重定向到以下网址:header('Location:'。$ next_url);
  3. the user will be returned by FB with session information about the login status FB将为用户返回有关登录状态的会话信息
  4. the SDK will parse the returned info SDK将解析返回的信息
  5. use $facebook->getUser(); 使用$ facebook-> getUser(); to get the access_token and userid (if logged in) 获取access_token和userid(如果已登录)

So far so good. 到现在为止还挺好。 The only problem is, this function (point 4) is broken since the transition to oAuth2.0 by Facebook API, see also this bug report: http://developers.facebook.com/bugs/295348980494364 The returned $_GET['session'] is useless in the new oAuth2.0 SDK, it was used in the old PHP-SDK v2 (current is 3.1.1). 唯一的问题是,自从Facebook API转换为oAuth2.0以来,此功能(第4点)已损坏,另请参见以下错误报告: http : //developers.facebook.com/bugs/295348980494364返回的$ _GET ['session ']在新的oAuth2.0 SDK中没有用,它在旧的PHP-SDK v2(当前为3.1.1)中使用。

So please let FB know that you have the same issue by adding a reproduction. 因此,通过添加复制品,请让FB知道您遇到相同的问题。

Cheers! 干杯!

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

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