EventBrite API event_search返回错误的日期

时间:2014-03-06 23:56:23

标签: javascript eventbrite

我使用下面的代码使用JavaScript / jQuery查询EventBrite。它会提取正确的事件,但无论事件的实际时间如何,时间总是在早上6:45。对我做错了什么想法?

// <script> included in <head>
http://evbdn.eventbrite.com/s3-s3/static/js/platform/Eventbrite.jquery.js


// external JS file, loaded after above script
$(document).ready(function(){

Eventbrite({'app_key': "__ValidKey__"}, function(eb){
    var options = { 'date':"Future",'organizer': "Lamplighters International", "sort_by":"date" };
    eb.event_search( options, function( response ){         
        $("#upcomingEvents").html(eb.utils.eventList( response, eb.utils.eventListRow ));
        console.log( $("#upcomingEvents").html() );
    [ ... ]

返回的其中一个事件显示了这个(为清晰起见而格式化):

<div class="eb_event_list_item" id="evnt_div_8625628487">
    <span class="eb_event_list_title">
        <a href="http://www.eventbrite.com/e/w100-basic-training-workshop-tickets-8625628487?aff=SRCH">W100 - Basic Training Workshop</a>
    </span>
    <span class="eb_event_list_date">Wed Mar 19 2014</span>
    <span class="eb_event_list_time">6:45am</span>
    <span class="eb_event_list_location">Lamplighters International</span>
</div>

该活动应于上午11点45分显示。这是EventBrite页面:http://www.eventbrite.com/e/w100-basic-training-workshop-tickets-8625628487?aff=SRCH

1 个答案:

答案 0 :(得分:1)

嗯......我只是复制了你的代码,看起来eb.utils.eventListRow正在吐出错误的时间。 API返回正确的start_date值。

我的建议是自己解析JSON结果。您可以将eb.utils.eventListRow响应作为JSON对象获取,而不是使用eb.event_search

function getEventbriteEvents() {
  Eventbrite({'app_key': "54XIQ35B73N6UXADDF", 'user_key':"12922547909277245491"}, function(eb){
    eb.event_search( {'date':"Future",'organizer': "Lamplighters International", "sort_by":"date"}, function( response ){
      console.log(response);
    });
  });
}

response变量将是一个JSON对象,其结构显示在此处(文档中的完整结果结构:http://developer.eventbrite.com/doc/events/event_search/):

{
    "events": [{
      "summary": {
        "total_items": 6,
        "first_event": 8625730793,
        "last_event": 8648687457,
        "filters": {
          "organizer": "Lamplighters International"
        },
        "num_showing": 6
    }
  },
  {
    "event": {
      "timezone": "America/Chicago",
      "id": 8625730793,
      "title": "W100 - Basic Training Workshop",
      "start_date": "2014-04-09 11:45:00",
      "end_date": "2014-04-09 13:00:00",
      "timezone_offset": "GMT-0500",
      [...tons more event info...]
    }
  },
    {[...more events...]}
}

希望能帮到你。祝你好运!