How can I get list of Facebook places inside bounds

六眼飞鱼酱① 提交于 2019-12-23 04:25:17

问题


I need to receive list of facebook places inside of given bounds (defined by NE and WS coordinates)

I call the following fql.query from javascript application:

 FB.api({
    method: "fql.query",

    query: "SELECT name,description,geometry,latitude,longitude,checkin_count,display_subtext FROM place WHERE latitude < '" + bounds.getNorthEast().lat() + "' and longitude < '" + bounds.getNorthEast().lng() + "' and latitude > '" +  bounds.getSouthWest().lat() + "' and longitude > '" +  bounds.getSouthWest().lng() +"'"
  },
  function(response) {
     /// 
 }

But I receive error 604

Your statement is not indexable. The WHERE clause must contain an indexable column. Such columns are marked with * in the tables linked from http://developers.facebook.com/docs/reference/fql 

As far as I can see the only indexed column in place table http://developers.facebook.com/docs/reference/fql/place/ is page_id. But I see no means to get this page_id from some other table.

Is there any (maybe more simple) way to receive facebook places within given bounds?


回答1:


You are right in that the FQL table can't be used since those columns are not indexed.
But you could try the Graph API call to Search for places within a particular location.
Eg - https://graph.facebook.com/search?type=place&center=37.76,-122.427&distance=1000&access_token=...
This comes from the Graph API doc here - https://developers.facebook.com/docs/reference/api/




回答2:


I made it with fql, I was inspired by this answer:

Facebook places: order results by distance

I searched not within bounds, but within distance from central point, but using the fql.query language:

    FB.api({
      method: "fql.query",
      query: "SELECT page_id, name, description, latitude, longitude, checkin_count, distance(latitude, longitude, '"  + centerlat + "', '" + centerlon + "') FROM place WHERE distance(latitude, longitude, '" + centerlat + "', '" + centerlon + "') < '" + distance +"'" 
      },
      function(response) {

      });

And it does exactly what I need - gives me the list of places which I can use.



来源:https://stackoverflow.com/questions/12167258/how-can-i-get-list-of-facebook-places-inside-bounds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!