Java – there is no padding on spring social Facebook
I'm trying to get a user location on spring social Facebook:
Facebook fb = ((Facebook) connection.getApi()); Page pg = fb.pageOperations().getPage(fb.userOperations().getUserProfile().getLocation().getId());
The problem is that pg.getlocation () returns null
I tried, too
fb.fetchObject(fb.userOperations().getUserProfile().getLocation().getId(),org.springframework.social.facebook.api.Location.class)
But it only fills in names, not countries or other fields
Try using graph API Explorer / v2 6/112286918797929? Fields = ID, name, location return as expected:
{ "id": "112286918797929","name": "Sacele","location": { "city": "Sacele","country": "Romania","latitude": 45.6167,"longitude": 25.6833 } }
Is this a spring social Facebook problem?
I am using spring social 1.1 4 and spring social Facebook 2.0 three
I also tried spring social for Facebook – get user location, but unfortunately not all places follow the name conventions city and country. Some of them only include the city in the name, not the country Besides, how can you get geographical coordinates?
Solution
I finally understand First, it doesn't apply to pageoperations, but it applies to graphapi
Code is
UserProfile userProfile = fb.userOperations().getUserProfile(); Page pg = fb.fetchObject(userProfile.getLocation().getId(),Page.class,"location");
The trick is to specify a third parameter that represents a field (you can specify multiple fields as strings) Now that the page is filled, you can look like pg.getlocation() Get the country as getcountry()