事件时间显示不正确的我的Facebook事件(通过Javascript提交) [英] Event Time displaying incorrectly for my Facebook event (submitted via Javascript)

查看:331
本文介绍了事件时间显示不正确的我的Facebook事件(通过Javascript提交)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个与Facebook进行交互的网站,并为用户创建活动。我正在使用Javascript来提交成功提交的事件。问题是,Facebook上显示的时间已经离开我提交的时间了。

I am currently writing a site that interacts with Facebook and creates events for users. I am using Javascript to submit the event, which is submitting successfully. The problem is, the time that is displayed on Facebook is way off from the time I am submitting.

这是我的代码:

var event = {
    start_time: '{{ show_time.start_time|date:'U' }}',
    name: 'Movie Night: ' + '{{ show_time.movie.title }}'
};

FB.api('/me/events', 'post', event, function(response) {
    // Send invites, etc...
});

是的,我们正在使用一些Django。

Yes, we're using some Django in there.

{{show_time.start_time | date:'U'}}将输入一个时期戳记。我也发送ISO 8601 datetime与相同的结果。目前,datetimes中没有时区信息。我不知道这是否导致了这个问题,因为测试,我已经将-06:00添加到start_time,在Facebook上仍然显示错误。

{{ show_time.start_time|date:'U' }} will put in an epoch timestamp. I have also send in an ISO 8601 datetime with the same results. Currently, we have no timezone information in the datetimes. I am not sure if that is causing the problem though, because to test, I had appended -06:00 to the start_time, and it still showed up wrong on Facebook.

令人困惑的是在Facebook上的文档中,他们显示出一条卷曲线,据说它会创建一个事件,而他们发送的start_time是一个历元时间戳。在同一页面的其他部分,他们说start_time必须是ISO 8601.我还读过,你需要将你的datetime转换为太平洋时间,然后转换为一个时代的时间戳,然后提交为start_time。我只是想知道正确的方式是什么。 Facebook文档似乎在这很糟糕,所以我希望SO可以帮助!谁通过Javascript API实际上通过Facebook创建了一个活动,并在网站上显示正确的时间?你是怎么做的?

What is confusing me is in the docs on Facebook, they show a curl line that supposedly creates an event, and the start_time they send in is an epoch timestamp. In other parts of the same page, they say the start_time must be ISO 8601. I have also read that you need to convert your datetime to Pacific time, then convert to an epoch timestamp, then submit that as the start_time. I just want to know what the correct way is. The Facebook docs seem to be pretty bad at this, so I'm hoping SO can help! Who has actually created an event with Facebook through the Javascript API and had it show up with the correct time on the site? How did you do it?

推荐答案

首先,Facebook事件时区管理有一个错误。如果您在API和Facebook上查看活动,您可以看到不同的日期。 API上的正确日期和Facebook上的错误日期,因为您通过API添加事件。如果您在Facebook上创建了该活动,API将显示错误的日期。

First of all, there is a bug on Facebook event timezone management. If you check an Event on the API and on Facebook, you can see different dates. The right date on the API and the wrong date on Facebook, because you add the event by the API. If you created the Event on Facebook, the API will show the wrong date.

如果您尝试任何API事件调用,您可以看到使用的格式:

If you try any API event call you can see the format used:

"end_time": "2010-03-15T00:30:00+0000"

您可以注意到,日期/时间格式是ISO 8601,您应该使用这个,但是大概时间戳应该可以工作。通过查看时区(UTC,+0000),您可以邀请您将本地日期转换为UTC(+0000),但这是问题。

As you can notice, the date/time format is ISO 8601 and you should use this but, probably, epoch timestamp should work. By looking at the timezone (UTC, +0000) you can guest that you should convert your local date to UTC (+0000) but this is the problem.

日期必须转换为PST / PDT时区,但保持UTC时区指示符(+0000),Mike Lambert发现 http://bugs.developers.facebook.net/show_bug.cgi?id=12558

The date must be converted to PST/PDT timezone, but keeping the UTC timezone designator (+0000) as Mike Lambert found http://bugs.developers.facebook.net/show_bug.cgi?id=12558


我猜这个API现在是
错误,但是可以预测的错误,而
修复它只会打破其他
开发人员。所以你可以认为这是一个
的文档错误:
http:// developers.facebook.com/docs/reference/api/event

应该说这些
ISO格式的UTC时间应该是
转换为PST / PDT以检索由
用户输入的事件的
时间。 (这不是UTC / GMT时间
事件将实际发生。)

It should really say these ISO-formatted UTC times should all be converted to PST/PDT to retrieve the time of the event as entered by the user. (Which is not the UTC/GMT time the event will actually occur.)

这篇关于事件时间显示不正确的我的Facebook事件(通过Javascript提交)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆