Get Places with RestFB

16 views
Skip to first unread message

Daniele Calise

unread,
Dec 14, 2018, 6:39:28 AM12/14/18
to RestFB
Hi,
I try this code:

 Connection<Place> targetedSearch = facebookClient25.fetchConnection("search", Place.class,
 Parameter.with("q", "Naples"), Parameter.with("type", "place"),Parameter.with("limit", 10));

It work and th Json result is:

{"data":[{"name":"Naples, Italy","id":"220258884652727"},{"name":"Naples","id":"597700053594808"},{"name":"Naples, Florida","id":"202005209838145"},{"name":"Naples","id":"544813405567062"},{"name":"Naples, North Carolina","id":"199428816766087"},{"name":"Naples International Airport","id":"679491022076689"},{"name":"Gulf of Naples","id":"523807380996534"},{"name":"Naples, New York","id":"198395113536123"},{"name":"Naples, California","id":"200755959959540"},{"name":"Naples City , Italy","id":"364452030307142"}]

Why in the result there isn't the location of the place but only place name and place id?
There is a Parameter for get only the places around me? Can i pass to restFb latitude and longitude?
Thank you
Daniele


Norbert Bartels

unread,
Dec 17, 2018, 3:27:35 AM12/17/18
to RestFB

Hi Daniele,

you can use the center and distance to find places around you. Because you already know how to use the parameter object, you only need to add to new parameters.

Parameter.with("center", "40.7304,-73.9921"), Parameter.with("distance", 1000)

To get different fields, you have to define which fields you need.

For example: Parameter.with("fields","name,checkins,picture")

Best Regards,

Norbert

Daniele Calise

unread,
Dec 17, 2018, 9:45:26 AM12/17/18
to RestFB
Hi,
Thank you for the answer, i have another two questions: Why the attribute "type" is always null?
Why i cant get Event's in the Search? I use this code:
Connection<Event> eventList = facebookClient25.fetchConnection("search", Event.class, Parameter.with("q", "Natale"), Parameter.with("type", "event"));
Thank you very mutch
Daniele

Norbert Bartels

unread,
Dec 18, 2018, 6:00:06 AM12/18/18
to RestFB

Hi Daniele,

you have to request the type parameter with the other fields and if it is part of the object (most of the time it is) you can get it.

The second part is easy. Since April 2018 only page and pagetopic are valid types for the search request. We highlighted this information in the RestFB docs.

Best regards,
Norbert

Daniele Calise

unread,
Dec 18, 2018, 10:13:57 AM12/18/18
to RestFB
Thank you very much.
Daniele
Reply all
Reply to author
Forward
0 new messages