How to add a Facebook Event with new Graph API

前端 未结 4 1569
北荒
北荒 2021-02-06 13:11

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条回答
  • 2021-02-06 13:16

    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"
    
    0 讨论(0)
  • 2021-02-06 13:25

    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.

    0 讨论(0)
  • 2021-02-06 13:38

    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.

    0 讨论(0)
  • 2021-02-06 13:42

    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.

    0 讨论(0)
提交回复
热议问题