1

我可以使用 Eventbrite PHP API 和这个示例事件列表代码来显示我的事件列表。这是提供身份验证的方式:

$authentication_tokens = array('app_key' => 'YOUR_APP_KEY',
                               'user_key' => 'YOUR_USER_KEY');

我从 Eventbrite 文档中了解到,您可以通过不提供身份验证令牌来优化列表以仅显示公共事件。但是,如果我排除:

,'user_key' => 'YOUR_USER_KEY' 

我收到以下错误消息:

Fatal error: Uncaught exception 'Exception' with message 'Invalid email address . [None]'.... 

谁能建议如何通过不提供身份验证令牌来仅显示 eventbrite 公共事件?

提前致谢,

4

2 回答 2

1

您正在使用的 API 调用按用户查找事件:

http://developer.eventbrite.com/doc/users/user_list_events/

通过不提供user_keyoruser字段(这是用户的电子邮件),它实际上没有任何意义。

如果您想获取公共事件的列表,可以使用event_searchAPI:

http://developer.eventbrite.com/doc/events/event_search/

curl http://www.eventbrite.com/json/event_search -G -d app_key=$EB_APP_KEY

所有字段都是可选的,因此通过省略所有字段,您可以有效地获得公共事件的列表。

于 2013-04-16T18:56:49.110 回答
0

对于其他想要实现相同目标的人,我想我会列出一些示例代码:

<!DOCTYPE HTML>
<html>
<head>
  <title>Eventbrite</title>

 <meta charset="UTF-8">

 </head>
 <body>

 <?php
 // load the API Client library
 include "eventbrite.php";

 // Initialize the API client
 // Eventbrite API / Application key (REQUIRED)
 // http://www.eventbrite.com/api/key/
 // Eventbrite user_key (OPTIONAL, only needed for reading/writing private user data)
 // http://www.eventbrite.com/userkeyapi
 $authentication_tokens = array('app_key' => 'YOURAPPKEYGOESHERE',
                                'user_key' => 'YOURUSERKEYGOESHERE');
 $eb_client = new Eventbrite( $authentication_tokens );

 // For more information about the features that are available through the Eventbrite API, see      http://developer.eventbrite.com/doc/
 // $events = $eb_client->user_list_events();

 $search_params = array(
     'organizer' => 'YOURORGANISERNAMEGOESHERE',
     'sort_by' => 'date',
 );
 $resp = $eb_client->event_search( $search_params );

 //mark-up the list of events that were requested
 // render in html - ?>
 <style type="text/css">
 .eb_event_list_item{
   padding-top: 20px;
 }
 .eb_event_list_title{
   position: absolute;
   left: 300px;
   width: 300px;
   overflow: hidden;
 }
 .eb_event_list_date{
   padding-left: 20px;
 }
 .eb_event_list_time{
   position: absolute;
   left: 200px;
 }
 .eb_event_list_location{
   position: absolute;
   left: 620px;
 }
 </style>

 <h1>My Event List:</h1>
 <?= Eventbrite::eventList( $resp, 'eventListRow'); ?>  

 </body>
 </html>

如果要更改返回数据的方式,请编辑 eventbrite.php 页面。例如,我想在日期中包含年份,所以我编辑了第 258 行,将 strftime 更改为

 strftime('%a, %e, %B, %Y', $time)

希望这可以帮助某人:)

于 2013-04-22T11:23:24.223 回答