5

I am trying to create an event using Facebooks api. (From a django app) Has anyone created an event with the new graph api?

4 Answers 4

7

Check here: http://developers.facebook.com/docs/api#publishing

Make a POST call to /PROFILE_ID/events with the required informations. Unfortunately they don't have all the possible arguments listed, but they can be found in the REST API docs under Events.create.

1
  • Ok, let me try this out. Looks like exactly what I wanted too see! Thanks so much! Any chance you know the encoding details on the image upload?
    – kkubasik
    Commented May 3, 2010 at 14:32
5

To Create Event you can use below code: (Which require create_event permission to achieve your requirement)

update_url = "https://graph.facebook.com/<Your_FacebookProfile_ID>/events"
form_fields = {
   "access_token": "Your Access Token",
   "start_time" : "1272718027",
   "location" : "someplace",
   "name" : "New Test Event Using Graph API"
}
temp = {}
for k, v in form_fields.iteritems():
  temp[k] = unicode(v).encode('utf-8')

form_data = urllib.urlencode(temp)
res = urlfetch.fetch(url=update_url,
                     payload=form_data,
                     method=urlfetch.POST,
                     headers={'Content-Type': 'application/x-www-form-urlencoded'})
result = json.loads(res.content)
if result.get('id', False):
   "Successfully Created Event"
else:
   "Failure"
1
  • Great answer! Very much what I have ended up doing. I've had a lot of problems getting the location set correctly, as well as uploading images. But I'm making progress!
    – kkubasik
    Commented Apr 19, 2011 at 1:06
2

If you require access to user data while the user is not online, there is the offline_access extended privilege which gives you a longer lived session key. This can be used to perform updates while the user is offline.

While I can't help you with Django, most of the Graph API does seem to work for me (not tried events unfortunately) but just seems badly documented.

1
  • I'm aware of the offline_access permission session solution. The big problem is knowing if I can create an event. It appears that the api will not allow it. It appears the only write access to the Graph API is really rsvp/comments/like and not much else.
    – kkubasik
    Commented Apr 29, 2010 at 16:17
-1

There appears to be no documented method for creating an API in the new docs, but you can use the REST interface methods as described here: http://developers.facebook.com/docs/reference/rest/ .

The big show stopper for me at the moment is the requirement of a user session to run any of the REST interfaces. A lot of my requests to Facebook (Event creations, invites) do not run during an active Facebook user logged in. They need to be created from the Application. I'm not sure as of yet if this is a limitation in the new API or just not implemented in the SDKs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.