How to add a Facebook Event with new Graph API

前端 未结 4 1568
北荒
北荒 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//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"
    

提交回复
热议问题