简体   繁体   中英

Accessing Facebook Cookie data through Java (without php-sdk)

I am using the server side flow for FB authentication (as mentioned on http://developers.facebook.com/docs/authentication/ ) and I am able to get the authentication token successfully. Now I want to implement this - 1) The server side is able to identify the user 2) When the user logs out of FB, my server code is able to detect this when the next request comes from the client.

The only way I could think of doing this was to save the Auth token as a cookie on the users end, associate the token with the userID on the server, and delete the cookie in the OnLogout event handler through the FB JavaScript SDK. I wanted to know if there is a better (recommended?) way for doing this. In particular, I wanted to use the FB cookies (cookies which FB.init creates) to do this. That cookie appears encrypted to me, and I can't find any documentation about decrypting it apart from Where to find the Facebook cookie? . I remember reading about some PHP SDK function which decrypts the cookie (GetUser) but I can't use that since my code is in Java. If possible, I'd want to avoid using 3rd party Facebook Java SDKs. I'd be grateful for any pointers about this.

Why do you want to avoid using a Java API that has already done all of this work for you?!

In any case, take a look at any of the existing Java/FB APIs--if you're unable to translate PHP to Java, might as well reinvent the wheel using code that already exists.

http://restfb.com/

If I were going about this I'd take an API that is known to work (like Koala for Rails ) and work backwards. Make sure to pick one that implements the mandatory OAuth 2 stuff, though.

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