Migrating FacebookAPI / restfb 1.6 to 1.36 results in deprecation warning and compile error

18 views
Skip to first unread message

ACTC

unread,
Feb 22, 2017, 5:26:43 AM2/22/17
to RestFB
Dear community,

I'm dealing with a legacy Java project that currently uses restfb with the outdated version 1.6.11. When updating the version to 1.36.0 some warnings popped up due to deprecated methods. Most of them complained about missing a com.restfb.Version, which I provided and everything is fine. But I'm a little stuck with the deprecation of com.restfb.types.User's  getUsername(). Consulting the JavaDoc is not helpful as it does not give a hint what to use instead:  

 /**
     * The user's Facebook username.
     *
     * @return The user's Facebook username.
     * @since 1.6.5
     * @deprecated since graph api 2.0
     */

   
@Deprecated
   
@Getter
   
@Setter
   
@Facebook
   
private String username;

What other method / other way is suitable to get that piece of information as it is needed further on in the code?

I also found a compile error concerning com.restfb.types.Page.getPicture(): once it returned a String as "the picture" which changed to com.restfb.types.ProfilePictureSource. Is ProfilePictureSource's url the same data as "the picture" or has this data to be processed?

Thanks in advance.

Norbert Bartels

unread,
Feb 23, 2017, 5:08:06 AM2/23/17
to RestFB

Hi there,

in the username was removed with Graph API 2.0 and there is not replacement. I think Facebook will force the use of the user id especially because the ids are app scoped now. With the username there would be a workaround for the app scoped ids. That’s why you only get the deprecation information in the Javadoc regarding Graph API 2.0.

Yes, the url is the former picture field. As you can see in the Graph API Explorer the picture field now returns a JSON and not only the String, so we had to change this accordingly.

Cheers,

Norbert

Reply all
Reply to author
Forward
0 new messages