Get event list based on location

前端 未结 2 1519
轻奢々
轻奢々 2021-02-06 20:05

I\'ve been digging around on the Facebook developer site to see if there is a way to get local event information for display on my own web app.

Ideally, I would pass up

2条回答
  •  清酒与你
    2021-02-06 20:22

    It is possible indeed to receive events using location based "search" To do so you'll need the longitude and latitude coordinates of the location you want to search and a access_token with user_events permission (i think you could also use the public search)

    Here's an FQL example how can you get all the events nearby of a location. (this searches from your and your friends events):

    $lat = "40";
    $long = "30";
    
    // using offset gives us a "square" on the map from where to search the events
    $offset = 0.4;
    
    $events = 'SELECT pic_big, name, venue, location, start_time, eid FROM event WHERE eid IN (SELECT eid FROM event_member WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND start_time > '. $created_time .' OR uid = me()) AND start_time > '. $created_time .' AND venue.longitude < \''. ($long+$offset) .'\' AND venue.latitude < \''. ($lat+$offset) .'\' AND venue.longitude > \''. ($long-$offset) .'\' AND venue.latitude > \''. ($lat-$offset) .'\' ORDER BY start_time ASC '. $limit;
    

    The trick itself lies in the venue.longitude and venue.latitude useage. To get events from a city, just get the city coordinates and adjust the offset to your needs. If you don't know how to use FQL please look into Facebook PHP SDK

提交回复
热议问题