ritamnrg / facebook-java-api

Automatically exported from code.google.com/p/facebook-java-api
0 stars 0 forks source link

Why FacebookJsonRestClient is not serializable?? #274

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago

Why FacebookJsonRestClient class is not serilizable and there is no way to
make it as serializable by extending it . Because there is no default
constructor.

I wanted to store the object of FacebookJsonRestClient in a session, I am
using Google App Engine and in GAE we cannot put non serialized object in
to a session.

is there any specific reason behind to make tihs class as non serializable???

Thanks,
-Sujith

Original issue reported on code.google.com by sujithpv...@gmail.com on 1 Dec 2009 at 9:36

GoogleCodeExporter commented 8 years ago
Incredible since I ran into the same problem and I had to implement a 
synchronized
hash map indexed by sessionid containing all the clients. And this class has to 
be a
listener for session events (in web.xml) in order to clear expired session's 
facebook
clients from this hash map.

Objects in session should be serializable and simple (POJOs). The facebook 
client in
its turn, could receive this POJO as an argument for its construction. Much 
more clean.

Original comment by darioand...@gmail.com on 8 Dec 2009 at 11:00

GoogleCodeExporter commented 8 years ago
Could you provide an example of this as a quick fix for this issue?

Thanks,
Tuomas

Original comment by tuomas.r...@gmail.com on 16 Dec 2009 at 4:08

GoogleCodeExporter commented 8 years ago
I think it's a bad idea to put FacebookJsonRestClient into a session. Why do 
you need
that?

Original comment by rdmytre...@gmail.com on 22 Dec 2009 at 6:06

GoogleCodeExporter commented 8 years ago
Why is that? Could you explain, because the example saves it in to a session. 
How the
login informatin should be saved then? 

Original comment by tuomas.r...@gmail.com on 5 Jan 2010 at 2:22

GoogleCodeExporter commented 8 years ago
Hi Tuomas, 
If we're talking about regular Facebook app (FBML or iframe based), you will 
always
have all needed parameters. if you have FbConnect application you need only
"session_key" as I understand (you can research junit tests to get idea).
"session_key" is a string and you can easy put it to session. You also will not 
waste
your server memory with large objects like FacebookJsonRestClient.

Original comment by rdmytre...@gmail.com on 5 Jan 2010 at 9:55

GoogleCodeExporter commented 8 years ago
Thanks.

Maybe this issue should be changed to "fix the example"..

// When initializing the facebook connection get the session key from POST 
parameter
String sesskey = request.getParameter("fb_sig_session_key");
session.setAttribute(FACEBOOK_USER_SESSION_KEY, sesskey);

// When creating the FacebookXmlRestClient again from session data
String sessionkey = (String)session.getAttribute(FACEBOOK_USER_SESSION_KEY);
new FacebookXmlRestClient(api_key, secret, sessionkey);

Original comment by tuomas.r...@gmail.com on 6 Jan 2010 at 2:04

GoogleCodeExporter commented 8 years ago
Hi Thomas,

Does the proposed solution

    String sessionkey = (String)session.getAttribute(FACEBOOK_USER_SESSION_KEY);
    new FacebookXmlRestClient(api_key, secret, sessionkey);

only apply to desktop applications, since the documentation seems to indicate 
that web based applications should no be concerned with the 'sessionkey'. 

Original comment by paul.t.oconnell@gmail.com on 1 Sep 2010 at 8:25