Thứ Năm, 10 tháng 8, 2017

Spring Social Facebook - Error (#12) bio field is deprecated for versions v2.8 and higher due to Facebook API version changes

When i'm trying to overcome the spring-boot-starter-social-facebook error: (#12) bio field is deprecated for versions v2.8 and higher due to Facebook API version changes. I used the workaround here: Error message is (#12) bio field is deprecated for versions v2.8 and higher
And I also want picture url, so I include "picture" in fields list:



Facebook facebook = new FacebookTemplate(accessToken);
String[] fields = {"id", "email", "name", "picture"};
User user = facebook.fetchObject("me", User.class, fields);

/*
"picture": {
    "data": {
        "url": "https://scontent...."
            }
           }
*/
if (user.getExtraData().containsKey("picture")) {
    try {
        LinkedHashMap<String, LinkedHashMap<String, String>> a = (LinkedHashMap<String, LinkedHashMap<String, String>>) user.getExtraData().get("picture");
        LinkedHashMap<String, String> d = a.get("data");
        String pictureUrl = d.get("url");
        }
        catch (Exception ex) {

        }
    }



The picture url is put in "extraData".

Không có nhận xét nào:

Đăng nhận xét