如何使用新的 Graph API 添加 Facebook 事件

发布于 2024-08-30 01:18:44 字数 72 浏览 2 评论 0原文

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

抹茶夏天i‖ 2024-09-06 01:18:44

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

进行 POST 调用到 /PROFILE_ID/events 并提供所需信息。不幸的是,他们没有列出所有可能的参数,但可以在 Events.create

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.

二智少女 2024-09-06 01:18:44

要创建事件,您可以使用以下代码:(需要 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"

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"
像极了他 2024-09-06 01:18:44

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

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

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.

暮色兮凉城 2024-09-06 01:18:44

新文档中似乎没有记录创建 API 的方法,但您可以使用此处描述的 REST 接口方法:http://developers.facebook.com/docs/reference/rest/

目前对我来说最重要的问题是需要用户会话来运行任何 REST 接口。我对 Facebook 的许多请求(活动创建、邀请)在 Facebook 活跃用户登录期间不会运行。它们需要从应用程序创建。
目前我还不确定这是否是新 API 中的限制,或者只是未在 SDK 中实现。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文