2017-08-10 187 views
0

我曾经使用fql从Place获取纬度和经度。从restfb获取纬度和经度

现在我该怎么做?我得到了用户的位置,但只填写了id和name。其他所有内容都是空的。代码:

FacebookClient fc = new DefaultFacebookClient(token, Version.VERSION_2_9); 
User user = fc.fetchObject("me", User.class, Parameter.with("location")); 
Location loc = fc.fetchObject(user.getLocation().getId(), Location.class); 

也试过:

Place pl = fc.fetchObject(user.getLocation().getId(), Place.class); 

同样的事情。

回答

1

正如我在RestFB bugtracker写道:

FacebookClient fc = new DefaultFacebookClient(token, Version.VERSION_2_9); 
User user = fc.fetchObject("me", User.class, Parameter.with("fields","location")); 
Page pageOfUserLocation = fc.fetchObject(user.getLocation().getId(), 
Page.class, Parameter.with("fields","location"); 
if (pageOfUserLocation.getLocation() != null) { 
    System.out.println("longitude: ", pageOfUserLocation.getLocation().getLongitude()); 
    System.out.println("latitude: ", pageOfUserLocation.getLocation().getLatitude()); 
} 
+0

谢谢! 还有一件事情,以防其他人在更新后像我一样:Page.getLocation()。getName()为null。但是user.getLocation()。getName()具有位置字符串。 –