3

When i create an event with the graph api i need to specify the venue and i would like also to show the map.

I do

$fb_event['name'] = "THis is to test latitude";
$fb_event['description'] = "And longitude!!!!";
$fb_event['start_time'] = date( "c", Ai1ec_Facebook_Event::get_facebook_start_time($event->start));
$fb_event['location'] = "Where you want";
$fb_event['street'] = "Via andrea del sarto 9";
$fb_event['city'] = "Milan";
$fb_event['latitude'] = 45.444975793404;
$fb_event['longitude'] = 9.2119209654715;

$facebook = $this->facebook_instance_factory();
try {
    $result = $facebook->api( "/me/events", "POST", $fb_event );
} catch (FacebookApiException $e) {
    fb($e);
}

This produce this event which show the correct street and city, but no map. If i edit the event and save, the map "Magically" appears using the street and city correctly.

In any case latitude and longitude are ignored.

What am i doing wrong?

CD Smith
  • 6,597
  • 7
  • 40
  • 66
Nicola Peluchetti
  • 76,206
  • 31
  • 145
  • 192

3 Answers3

2

If you compare your two test events in the Graph API explorer you'll see that Event ID 239298922846828 does not have its latitude and longitude populated, while 245655182207213 does. I'm assuming 245655182207213 is an event you've edited.

Looking at your code, you seem to be doing everything as described in the documentation. However, I've found that what is described does not always work.

What I've been seeing is that events populated from within Facebook that occur at a known venue are no longer allowing you to specify an address. Instead all they save is a venue id within Facebook which you can then drill into to get the address, etc.

Take a look at one of my events. For this event, there is no way to edit the details of this location from within Facebook, nor does the event venue details get returned with an API call. I'm using the API to pull the event details to an external website. This change caused me days of frustration.

I started seeing this behavior in late April. I haven't found any official documentation announcing this change.

When some documentation appears, what I expect the new event venue workflow will be is something like:

  • Query the area where your event will take place to see if a venue exists already.
    • If yes, get save its id.
    • If not, create a new community page for your venue and save its id.
  • Use this ID to populate the event venue.
cpilko
  • 11,792
  • 2
  • 31
  • 45
  • Before implementing this behaviour (writing my events to facebook) i implemented the other behaviour (importing facebook events) and did exactly what you describe. It appears that the Facebook API behaves differently when you write thing in respect to when you read things. It seems like it's still stuck with the old rest api only wrapped into new methods – Nicola Peluchetti May 30 '12 at 12:02
  • This is a known facebook bug https://developers.facebook.com/bugs/173095916131752 – Nicola Peluchetti May 30 '12 at 12:23
  • It would be nice if Facebook's behavior was consistent. I see changes in it nearly every week, many of them undocumented. I agree with you that much of this is similar to the old REST API, the difference is these new methods are slowly limiting the power that you used to have. – cpilko May 30 '12 at 12:31
0

In the end this is a known facebook bug

https://developers.facebook.com/bugs/173095916131752

Nicola Peluchetti
  • 76,206
  • 31
  • 145
  • 192
0

Two different formats when create using the same parameters.

When create event through gql

{
  "id": "xxxxxxxxxxxxxx", 
  "owner": {
    "name": "xxxxxxxxxx", 
    "id": "xxxxxxxxx"
  }, 
  "name": "W1112", 
  "start_time": "2013-10-22", 
  "is_date_only": true, 
  "location": "Tulsa, OK, United States", 
  "venue": {
    "latitude": 36.131388888889, 
    "longitude": -95.937222222222, 
    "street": "", 
    "zip": "", 
    "id": "109436565740998"
  }, 
  "privacy": "SECRET", 
  "updated_time": "2013-09-19T12:23:26+0000"
}





When create event through fb
{
  "id": "xxxxxxxxxxxxxx", 
  "owner": {
    "name": "xxxxxx", 
    "id": "xxxxxxxx"
  }, 
  "name": "1234", 
  "start_time": "2013-10-09T21:26:00+1100", 
  "end_time": "2013-10-25T00:26:00+1100", 
  "timezone": "Australia/Sydney", 
  "is_date_only": false, 
  "location": "Maroubra Junction", 
  "venue": {
    "latitude": -33.940804216453, 
    "longitude": 151.23876752992, 
    "city": "Maroubra", 
    "state": "NSW", 
    "country": "Australia", 
    "id": "153993547968514", 
    "street": "832 anzac Parade ", 
    "zip": "2035"
  }, 
  "privacy": "SECRET", 
  "updated_time": "2013-09-19T10:50:14+0000"
}
Thirumalai murugan
  • 5,698
  • 8
  • 32
  • 54
iceman
  • 181
  • 1
  • 7