Codigami / face4j

face4j is a java library for facebook's new graph API

Home Page:http://face4j.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Facebook user.getEmail() == null

madmaxmatze opened this issue · comments

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?

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.

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.

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.

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)
...

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?

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

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.

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?

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.

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.

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

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

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

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

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.

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!

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.