简体   繁体   English

Facebook JS SDK和PHP SDK没有刷新?

[英]Facebook JS SDK & PHP SDK without refreshing?

I currently have the facebook js sdk to login to the site and then I want to use the PHP sdk for everything else. 我目前有facebook js sdk登录该网站,然后我想将PHP sdk用于其他一切。 How can I pass the accessToken to the PHP SDK to allow me to do this? 如何将accessToken传递给PHP SDK以允许我这样做? I want to pass it to a PHP script at a different url, so for example I login at /login/ and then open up a modal box to /facebook/?accessToken=gfdhjsfghjkfgdh or what ever. 我想将它传递给不同网址的PHP脚本,所以例如我登录/login/然后打开一个模式框到/facebook/?accessToken=gfdhjsfghjkfgdh或者什么。

http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/ http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/

Please check this link. 请检查此链接。

A sample code may look like this, 示例代码可能如下所示,

FB.getLoginStatus(function(response) {
  if (response.status === 'connected') {
    //got the token
    var accessToken = response.authResponse.accessToken;
    //send it to php via _GET
    window.location = "/facebook/?accessToken=" + accessToken;
  } else if (response.status === 'not_authorized') {
    // the user is logged in to Facebook, 
    //but not connected to the app
  } else {
    // the user isn't even logged in to Facebook.
  }
 });

You can get the accesstoken then send it to php. 您可以获取accessstoken然后将其发送到PHP。

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

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