Codigami / face4j

face4j is a java library for facebook's new graph API
http://face4j.org
23 stars 6 forks source link

Facebook user.getEmail() == null #13

Open madmaxmatze opened 12 years ago

madmaxmatze commented 12 years ago

In very rare cases the Facebook User Object I create from the OAuthAccessToken has an id and seems fine, but has null as its email address.

Is this behavior common? Is it connected to the facebook Api or to face4j?

nischal commented 12 years ago

I will have to look into this. But unless facebook does not return the email, this should not occur. As far as I know, the new facebook permissions dialog allows users to choose not to provide a particular info. Any idea if they are allowed to strike off email while providing permission? That would help understand this problem better.

madmaxmatze commented 12 years ago

I just tried the facebook authentication again and see no way of disabling the required email permission. The only thing you can do is send a xxx@proxy.facebook.com email instaed of the email address you registered with. The proxy email addresses work fine. I see them a lot.

nischal commented 12 years ago

thanks for checking that out. I'll look into it but there's not much code in there. It's gson which does conversion from json to java object. And if it works once, then it should work every time unless the data received has some problem in it. I will try to look into this, though I have a feeling this would take longer to find the cause. If you come across a way to replicate this bug then please do let me know.

madmaxmatze commented 12 years ago

I will keep my eyes open. What I also get from time to time is a NumberFormatException (this and the empty email issue are not happening at the same time):

com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: empty String at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:231) at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:221) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:86) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:170) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:86) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:170) at com.google.gson.Gson.fromJson(Gson.java:720) at com.google.gson.Gson.fromJson(Gson.java:686) at com.google.gson.Gson.fromJson(Gson.java:636) at com.google.gson.Gson.fromJson(Gson.java:608) at com.face4j.facebook.util.JSONToObjectTransformer.getUser(JSONToObjectTransformer.java:24) at com.face4j.facebook.Facebook.getUser(Facebook.java:73) at com.face4j.facebook.Facebook.getCurrentUser(Facebook.java:53) ... Caused by: java.lang.NumberFormatException: empty String at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1018) at java.lang.Double.parseDouble(Double.java:527) at com.google.gson.stream.JsonReader.nextLong(JsonReader.java:573) at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:229) ...

nischal commented 12 years ago

Oh, in the User object, currently timezone has datatype Double. I'm guessing facebook sends an empty string at times when there is no timezone set for a user. I will try to get this fixed. Also, which face4j version are you using?

madmaxmatze commented 12 years ago

It's hard to tell which version I'm using, since the file itself is called facebook-0.1.jar... At least the last modified date of the file says 14. October 2011 - downloaded from github

nischal commented 12 years ago

I think it's an old version. I would recommend you to upgrade to the latest version as I've done some bug fixes. I've just uploaded a new zip - https://github.com/downloads/nischal/face4j/dist-1.5.7.zip

Let me know if you have any issues integrating it with your current code.

madmaxmatze commented 12 years ago

My dependencies come from the central maven repository. From there I fetch the newest versions gson 2.1, commons-codec 1.6, commons-logging 1.1.1, commons-http-client 3.1

BTW: Why are you not using maven?

nischal commented 12 years ago

I have never used maven before. Will need to learn it and do it. I will try to do this soon. I guess that would help others too.

madmaxmatze commented 12 years ago

I had to get into it mid last year because a client requested it. Soon after I loved it and also migrated all my private projects to maven dependency resolution, cause it's so nice.

nischal commented 12 years ago

Nice! I'll definitely use maven then. Will try to look into it over the weekend, thanks :)

madmaxmatze commented 12 years ago

Newest face4j version is now live - I will keep you updated if the 2 mentioned issue still occur.

madmaxmatze commented 12 years ago

Update: With face4j v1.5.7 the NumberFormatException still occures.

nischal commented 12 years ago

I'll get it fixed. Will change the datatype for timezone to string.

nischal commented 12 years ago

This - https://github.com/downloads/nischal/face4j/dist-1.5.9.zip should fix the NumberFormatException If it still occurs then please post the stack trace and I will get it fixed.

madmaxmatze commented 12 years ago

Good work. Since yesterday they NumberFormatException disappeared from the log and the percentage off users joining with facebook strongly increased ;) ...but I still see the user.getEmail()==null error a few times a day.

Thanks a lot!

nischal commented 12 years ago

glad to know that. The email exception is tricky because I haven't been able to reproduce it yet :( In case you get a definite scenario that can be reproduced please do let me know. I'll keep an eye out on this one.