dimanche 27 novembre 2016

What URL to hit to log out of Facebook through java APIs?

I am using the below code to log into Facebook. Once i get the code, using that i get access token and then query graph api and get some basic details.

@RequestMapping(value = "/fblogin")
        public String inititateFBlogin(ModelMap model) {

            System.out.println("in FB login ");

            String fbAuthURL = fbConnectionService.getFBAuthUrl();


            return  "redirect:"+fbAuthURL;

        }


        public String getFBAuthUrl() {
                String fbLoginUrl = "";
                try {
                    fbLoginUrl = "http://ift.tt/VyM1TP?" + "client_id="
                            + FBConnection.FB_APP_ID + "&redirect_uri="
                            + URLEncoder.encode(FBConnection.REDIRECT_URI, "UTF-8")
                            + "&scope=email";
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
                return fbLoginUrl;
            }

But to logout , i am hitting the URL in below format. //http://ift.tt/1rjUmp0]

@RequestMapping(value = "/fblogout", method=GET)
    public String  fbLogOut(ModelMap model) {


        String fbLogoutURL = "http://ift.tt/2foKPB4";


        String appURL = "http://localhost:15005/abc";

        String accessToken = accessTokenFB ;

        String logOutURL =   fbLogoutURL+appURL+"&access_token="+accessToken;

        return "redirect:"+logOutURL;

    }

But looks like the above FB url always redirects to the FB homepage. Is there any way that i can log out by simply calling any FB service through java, I would rather avoid going down to the javascript SDK. Many thanks.




Aucun commentaire:

Enregistrer un commentaire