简体   繁体   中英

Facebook fails to redirect to application URL after login

I am creating facebook application. If user is not logged on facebook I redirect them to FaceBook login that redirects to my application URL after they logged to facebook. Problem is that user is redirected to facebook.com insted of facebook application URL

Here is code that I am using to check if user logged to FaceBook

  function statusChangeCallback(response) {
    if (response.status === 'connected') {
      // Logged into your app and Facebook.
      FillInfo();
    } else if (response.status === 'not_authorized') {
    window.top.location("https://apps.facebook.com/memorygameonfb/?fb_source=bookmark&ref=bookmarks&count=0&fb_bmpos=3_0")
    } else {
      // The person is not logged into Facebook, so we're not sure if
      // they are logged into this app or not.
window.top.location = "https://www.facebook.com/login.php?api_key=id&skip_api_login=1&display=page&redirect_uri=https://apps.facebook.com/memorygameonfb/?fb_source=bookmark&ref=bookmarks&count=0&fb_bmpos=3_0";    }
  }

The reason they are being redircted to facebook.com is becasue that is where you are sending them

You need to create $params so when your user logs in you can redirect them to your app.

You can find the dox on this Here

$params = array(
  'scope' => 'read_stream, friends_likes',
  'redirect_uri' => 'https://www.myapp.com/post_login_page' //This redirects to ur APP!
);

$loginUrl = $facebook->getLoginUrl($params);

I personally am not great with JS I use php for facebook api I think it is easier to manage then the JS API

If you would like to download a basic app allowing you to login with php

Click Here and follow the readme file for instructions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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