2017-08-10 185 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()具有位置字符串。 –