5

我正在尝试使用 Facebooks api 创建一个事件。(来自 django 应用程序)是否有人使用新的图形 API 创建了一个事件?

4

4 回答 4

7

在这里查看:http: //developers.facebook.com/docs/api#publishing

使用所需信息对 /PROFILE_ID/events 进行 POST 调用。不幸的是,它们没有列出所有可能的参数,但可以在Events.create下的 REST API 文档中找到它们。

于 2010-04-30T19:47:13.070 回答
5

要创建事件,您可以使用以下代码:(需要create_event权限才能实现您的要求)

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"
于 2011-04-04T17:37:25.563 回答
2

如果您需要在用户不在线时访问用户数据,则可以使用 offline_access 扩展权限,为您提供更长寿命的会话密钥。这可用于在用户离线时执行更新。

虽然我无法帮助您使用 Django,但大多数 Graph API 似乎确实对我有用(不幸的是没有尝试过事件),但似乎记录得很糟糕。

于 2010-04-29T09:24:32.467 回答
-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.

于 2010-04-23T12:47:09.623 回答