示例#1
1
    foreach ($fields as $key => $value) {
        $fields_string .= $key . '=' . $value . '&';
    }
    rtrim($fields_string, '&');
    //open connection
    $ch = curl_init();
    //set the url, number of POST vars, POST data
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, count($fields));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    // delivers html without auto echo
    $result = curl_exec($ch);
    curl_close($ch);
    // close connection
    $obj = json_decode($result);
    $access_token = $obj->{'access_token'};
    echo "access: {$access_token} -- eb id: {$eventbrite_id}";
    $eb_client = new Eventbrite(array('access_token' => $access_token));
    $resp = $eb_client->event_get(array('id' => $eventbrite_id));
    echo "ok: {$resp}";
}
?>
				
				</div>
				
				<script>
            //App custom javascript
        </script>
    </body>
</html>
示例#2
1
 public static function loginWidget($options, $get_token = 'getAccessToken', $save_token = 'saveAccessToken', $delete_token = 'deleteAccessToken', $render_login_box = 'widgetHTML')
 {
     if (isset($options['logout_link']) && $options['logout_link'] == $_SERVER['REQUEST_URI'] || isset($_GET['eb_logout']) && $_GET['eb_logout'] == "true") {
         // clear this user's access_token -
         Eventbrite::deleteAccessToken();
         // remove our "logout=true" trigger from the querystring-
         header("Location: " . $_SERVER['PHP_SELF']);
         exit;
     }
     // automatically pull the access_code from the querysting?
     // TODO: add a way to disable this:
     if (!isset($options['access_code'])) {
         $options['access_code'] = isset($_REQUEST['code']) ? $_REQUEST['code'] : null;
     }
     // automatically grab errors from the querystring?
     // TODO: add a way to disable this:
     if (!isset($options['error_message'])) {
         $options['error_message'] = isset($_REQUEST['error']) ? $_REQUEST['error'] : null;
     }
     //  Check to see if we have a valid user account
     //  and Proccess any data-related work:
     $response = Eventbrite::OAuthLogin($options, $get_token, $save_token, $delete_token);
     //  package up the data for our view / template:
     $login_params = array();
     if (is_array($response)) {
         if (isset($response['user_email'])) {
             $login_params = array('user_name' => $response['user_name'], 'user_email' => $response['user_email']);
         }
         $login_params['oauth_link'] = Eventbrite::oauthNextStep($options['app_key']);
         if (isset($response['login_error'])) {
             $login_params['login_error'] = $response['login_error'];
         }
         if (isset($options['logout_link'])) {
             $login_params['logout_link'] = $options['logout_link'];
         } else {
             $login_params['logout_link'] = $_SERVER['PHP_SELF'] . '?eb_logout=true';
         }
     }
     // view related work:
     //  render your "template"
     if (is_callable($render_login_box)) {
         return $render_login_box($login_params);
     } elseif (is_callable(array('self', $render_login_box))) {
         return self::$render_login_box($login_params);
     } else {
         //the templating callback was not valid,
         //return the raw data for use with an external template
         return $login_params;
     }
 }
<?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' => 'YOUR_APP_KEY', 'user_key' => 'YOUR_USER_KEY');
$eb_client = new Eventbrite($authentication_tokens);
try {
    // For more information about the functions that are available through the Eventbrite API, see http://developer.eventbrite.com/doc/
    $attendees = $eb_client->event_list_attendees(array('id' => 'YOUR_EVENT_ID'));
} catch (Exception $e) {
    // Be sure to plan for potential error cases
    // so that your application can respond appropriately
    //var_dump($e);
    $attendees = array();
}
function attendee_to_html($attendee)
{
    if ($attendee->first_name) {
        return "<div class='eb_attendee_list_item'>" . $attendee->first_name . ' ' . $attendee->last_name . "</div>\n";
    } else {
        return '';
    }
}
function sort_attendees_by_created_date($x, $y)
{
    if ($x->attendee->created == $y->attendee->created) {
<?php

// load the API Client library
include "../Eventbrite.php";
// Initialize the API client
//  Eventbrite API / Application key (REQUIRED)
//   http://www.eventbrite.com/api/key/
$api_key = 'YOUR_API_KEY';
//  Eventbrite user_key (OPTIONAL, only needed for reading/writing private user data)
//   http://www.eventbrite.com/userkeyapi
$user_key = 'YOUR_USER_KEY';
//The event_id that you would like to copy and update:
$draft_event_id = 'YOUR_DRAFT_EVENT_ID';
//see http://developer.eventbrite.com/doc/events/event_update/ for a
// description of the available event_update parameters:
$event_update_params = array('title' => 'NEW EVENT TITLE', 'start_date' => date('Y-m-d H:i:s', time() + 7 * 24 * 60 * 60), 'end_date' => date('Y-m-d H:i:s', time() + 7 * 24 * 60 * 60 + 2 * 60 * 60), 'privacy' => 1);
// initialize the API client
$eb_client = new Eventbrite(array('app_key' => $api_key, 'user_key' => $user_key));
//Copy and Update your saved "Draft" event.
//Keep the original around for additional copying in the future.
try {
    // For more information about the API calls that are available
    // on Eventbrite API clients, see http://developer.eventbrite.com/doc/
    $new_event = $eb_client->event_copy(array('event_id' => $draft_event_id))->event;
    $new_event_params['event_id'] = $new_event['id'];
    $response = $eb_client->event_update($event_update_params)->event;
} catch (Exception $e) {
    // application-specific error handling goes here:
    $response = $e->error;
}
print var_dump($response);
<?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' => 'YOUR_APP_KEY', 'user_key' => 'YOUR_USER_KEY');
$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/
// event_get example - http://developer.eventbrite.com/doc/events/event_get/
$resp = $eb_client->event_get(array('id' => '1848891083'));
print Eventbrite::ticketWidget($resp->event);
// event_search example - http://developer.eventbrite.com/doc/events/event_search/
$search_params = array('max' => 2, 'city' => 'San Francisco', 'region' => 'CA', 'country' => 'US');
$resp = $eb_client->event_search($search_params);
// user_list_events example
$user_resp = $eb_client->user_list_events();
//mark-up the list of events that were requested
// render in html -
?>

<h1>Search Results:</h1>
<?php 
echo Eventbrite::eventList($resp, 'eventListRow');
?>

<br/> <hr/> <br/>
<?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' => 'YOUR_APP_KEY', 'user_key' => 'YOUR_USER_KEY');
$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();
//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: 220px;
  width: 300px;
  overflow: hidden;
}
.eb_event_list_date{
  padding-left: 20px;
}
.eb_event_list_time{
  position: absolute;
## Requirements and prep-work: ##
// 1. You must have an API key - Eventbrite API keys are available here: http://www.eventbrite.com/api/key/
// 2. Have your Client_Secret ready - Your API_Key's Client secret is available on the same page.  Keep it secret!  Be careful not to expose it to your users or check it in to publicly available source code.
// 3. Update your API_Key's "redirect_uri" setting on http://eventbrite.com/api/key.  Point your redirect_uri to the URL on your site where you expect a user to complete their OAuth2.0 authorization.  Or, point it to any URL on your site where our loginWidget is available.
// 4. Developer terms - To comply with our developer terms, your user's "access_tokens" should be protected, and should not be exposed to other users.
// 5. Download Eventbrite's PHP API client and add it to your application's source code - https://raw.github.com/ryanjarvinen/eventbrite.php/master/Eventbrite.php
//    the 'php5-curl' package may also be a requirement
## Implementing OAuth for Eventbrite in two easy steps: ##
// 1. load the API Client library:
require_once "../Eventbrite.php";
// 1a. (optional) This example uses PHP's built-in $_SESSION storage:
// See the README file for information about integrating with other data-stores.
// This line may be needed to enable session support on your server:
session_start();
// 2. Create a login widget OR redirect:
$login_widget_html = Eventbrite::loginWidget(array('app_key' => 'YOUR_APP_KEY', 'client_secret' => 'YOUR_CLIENT_SECRET'));
?>
<html>
  <?php 
echo $login_widget_html;
?>

  <?php 
// -------------- Done! ------------- //
// Optional debug output - Remove this in your app:
if (Eventbrite::getAccessToken()) {
    print "<p><b>DEBUG:</b> This user's OAuth2.0 access_token is: " . Eventbrite::getAccessToken() . "</p>";
}
?>
</html>
示例#8
0
    $params['user_key'] = $_POST['user_key'];
    $params['output_file_name'] = $_POST['output_file_name'];
    $params['timezone'] = $_POST['timezone'];
    $params['before_period'] = $_POST['before_period'];
    $params['after_period'] = $_POST['after_period'];
    $config->setConfig($params);
    $config->write();
}
// $config->read();
$app_key = $config->getParam('app_key');
$user_key = $config->getParam('user_key');
$output_file_name = $config->getParam('output_file_name');
$before_period = $config->getParam('before_period');
$after_period = $config->getParam('after_period');
// Get the user data ...
$eb_client = new Eventbrite(array('app_key' => $app_key, 'user_key' => $user_key));
try {
    $user = $eb_client->user_get();
} catch (Exception $ex) {
    // No events means the key is no good
    // This is a validation that should be reported, but for now
    // we just clear the params ...
    $message = $ex->getMessage();
}
?>
        <!-- Use the .htaccess and remove these lines to avoid edge case issues.
             More info: h5bp.com/i/378 -->
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></meta>

        <title>Eventbrite iCalendar Interface</title>
        <meta name="description" content=""></meta>
示例#9
-1
 public static function getOauthLink()
 {
     $app = Slim::getInstance();
     return Eventbrite::oauthNextStep($app->config('api_key'));
 }
<?php

// load the API Client library
include "../Eventbrite.php";
// Initialize the API client
//  Eventbrite API / Application key (REQUIRED)
//   http://www.eventbrite.com/api/key/
$api_key = 'YOUR_API_KEY';
//  Eventbrite user_key (OPTIONAL, only needed for reading/writing private user data)
//   http://www.eventbrite.com/userkeyapi
$user_key = 'YOUR_USER_KEY';
//see http://developer.eventbrite.com/doc/events/event_update/ for a
// description of the available event_update parameters:
$event_new_params = array('title' => 'NEW EVENT TITLE', 'start_date' => date('Y-m-d H:i:s', time() + 7 * 24 * 60 * 60), 'end_date' => date('Y-m-d H:i:s', time() + 7 * 24 * 60 * 60 + 2 * 60 * 60), 'privacy' => 1, 'timezone' => 'GMT-8');
// initialize the API client
$eb_client = new Eventbrite(array('app_key' => $api_key, 'user_key' => $user_key));
// Create your event:
try {
    // For more information about the API calls that are available
    // on Eventbrite API clients, see http://developer.eventbrite.com/doc/
    $response = $eb_client->event_new($event_new_params)->event;
} catch (Exception $e) {
    // application-specific error handling goes here:
    $response = $e->error;
}
print var_dump($response);