All Projects → jamiehollern → eventbrite

jamiehollern / eventbrite

Licence: GPL-2.0 license
A lightweight PHP library for interacting with version 3 of the Eventbrite API.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to eventbrite

Guzzle Rate Limiter Middleware
A rate limiter middleware for Guzzle
Stars: ✭ 94 (+370%)
Mutual labels:  guzzle
php-server-sdk
LaunchDarkly Server-side SDK for PHP
Stars: ✭ 31 (+55%)
Mutual labels:  guzzle
behat-3-kickstart
Behat 3/Mink and Guzzle for API testing. Code follows PageObjects approach. Saucelabs integration.
Stars: ✭ 13 (-35%)
Mutual labels:  guzzle
Guzzle Advanced Throttle
A Guzzle middleware that can throttle requests according to (multiple) defined rules. It is also possible to define a caching strategy, e.g. get the response from cache when the rate limit is exceeded or always get a cached value to spare your rate limits. Using wildcards in host names is also supported.
Stars: ✭ 120 (+500%)
Mutual labels:  guzzle
Yurunhttp
YurunHttp 是开源的 PHP HTTP 客户端,支持链式操作,简单易用。完美支持Curl、Swoole 协程。QQ群:17916227
Stars: ✭ 197 (+885%)
Mutual labels:  guzzle
guzzle-psr18-adapter
A simple guzzle PSR-18 adapter
Stars: ✭ 13 (-35%)
Mutual labels:  guzzle
Guzzle Jsonrpc
JSON-RPC 2.0 client for Guzzle
Stars: ✭ 87 (+335%)
Mutual labels:  guzzle
PhpBotFramework
A framework for Telegram Bot API written in PHP.
Stars: ✭ 56 (+180%)
Mutual labels:  guzzle
Guzzle Services
Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.
Stars: ✭ 226 (+1030%)
Mutual labels:  guzzle
guzzle-oauth2-subscriber
OAuth 2.0 Client for Guzzle 4, 5, 6 and 7 with PHP 5.4 - PHP 8.0 - no more dependency hell!
Stars: ✭ 112 (+460%)
Mutual labels:  guzzle
Snorlax
A lightweight REST client that gives you full control of your resources
Stars: ✭ 129 (+545%)
Mutual labels:  guzzle
Crawler
An easy to use, powerful crawler implemented in PHP. Can execute Javascript.
Stars: ✭ 2,055 (+10175%)
Mutual labels:  guzzle
twitter-stream-api
🐤 Another Twitter stream PHP library to retrieve filtered tweets on hot.
Stars: ✭ 11 (-45%)
Mutual labels:  guzzle
Microservices With Lumen
A Lumen based microservice ready to deploy with guzzle for consumption of api and OAuth 2
Stars: ✭ 115 (+475%)
Mutual labels:  guzzle
guzzle-log-middleware
A Guzzle middleware to log request and responses automatically
Stars: ✭ 61 (+205%)
Mutual labels:  guzzle
Guzzle retry middleware
Middleware for Guzzle v6+ that automatically retries HTTP requests on 429, 503 responses.
Stars: ✭ 90 (+350%)
Mutual labels:  guzzle
oauth2-middleware
PSR7 middleware that uses league/oauth2-client to authenticate outgoing requests
Stars: ✭ 21 (+5%)
Mutual labels:  guzzle
GuzzleBundleOAuth2Plugin
OAuth2 Plugin for GuzzleBundle
Stars: ✭ 13 (-35%)
Mutual labels:  guzzle
jacky
🐄 HTTP JSON API Client for Laravel & Lumen
Stars: ✭ 17 (-15%)
Mutual labels:  guzzle
php-curl-cookbook
PHP CURL Cookbook 📖
Stars: ✭ 83 (+315%)
Mutual labels:  guzzle

Eventbrite PHP

Deprecated! This project contains bugs and is no longer actively maintained. Use at your own risk.

A lightweight PHP wrapper for the Eventbrite API v3 using Guzzle 6.

Build Status Coverage Status Scrutinizer Code Quality Total Downloads Latest Stable Version License

Requirements

  • PHP >= 5.5
  • cURL if you don't want any extra config (see the Guzzle docs)

Installation

Install via Composer command:
composer require jamiehollern/eventbrite

Install via composer.json:

{
  "require": {
    "jamiehollern/eventbrite": "1.0.1"
  }
}

Once you've done this:

  • Run composer install
  • Add the autoloader to your script require_once('vendor/autoload.php')

Authentication

This API does not deal with the OAuth authentication flow. It assumes that your app has already been authenticated and that you have an OAuth token for any accounts you're going to use. It is this OAuth token that should be passed to the class on instantiation.

You can find out more about the Eventbrite authentication process on the Eventbrite API docs. If you only have a single app to authenticate you can simply get a premade OAuth token by adding an app on your Eventbrite apps page.

Examples

Instantiating the class

Basic usage

To get started, you only need an OAuth token to pass into the Eventbrite class:

<?php

use jamiehollern\eventbrite\Eventbrite;

$eventbrite = new Eventbrite('MY_OAUTH_TOKEN');

?>

You can check that everything's working okay by running:

<?php

use jamiehollern\eventbrite\Eventbrite;

$eventbrite = new Eventbrite('MY_OAUTH_TOKEN');
// Returns true if you can connect.
$can_connect = $eventbrite->canConnect();

?>

Advanced options

You can take advantage of the fact that this library is a fairly light wrapper around Guzzle if you need more advanced options while connecting.

To increase the timeout limit from the default 30 seconds to 60 seconds:

<?php

use jamiehollern\eventbrite\Eventbrite;

$eventbrite = new Eventbrite('MY_OAUTH_TOKEN', ['timeout' => 60]);

?>

If you don't have cURL installed, you can add a different HTTP request handler when instantiating the class. See the Guzzle docs for more information.

<?php

use jamiehollern\eventbrite\Eventbrite;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Handler\StreamHandler;

$handler = new StreamHandler();
$stack = HandlerStack::create($handler);
$eventbrite = new Eventbrite('MY_OAUTH_TOKEN', ['handler' => $stack]);

?>

Making requests

There are three ways of making requests with the library and all of them roughly amount to the same thing, but with various levels of abstraction:

  • makeRequest
  • call
  • get/post/put/patch/delete

Each of the following examples make the same call, using Eventbrite expansions.

The makeRequest method

This method is a wrapper around the call method and differs only in the parameters it takes. It is designed to be slightly more obvious than call in that the parameters explicitly outline what to do with the method.

<?php

use jamiehollern\eventbrite\Eventbrite;

$eventbrite = new Eventbrite('MY_OAUTH_TOKEN');

// Get all of the current users' ticket orders and ensure that the event 
// data and the event venue data are present in full.
$eventbrite->makeRequest('GET', 'users/me/orders/', ['expand' => 'event.venue']);

?>

The shortcut methods

The shortcut methods are simply methods named for the HTTP verbs and are identical to the makeRequest method but for the fact that the first parameter of makeRequest is the actual name of the shortcut method. The methods available are get, post, put, patch and delete.

<?php

use jamiehollern\eventbrite\Eventbrite;

$eventbrite = new Eventbrite('MY_OAUTH_TOKEN');

// Get all of the current users' ticket orders and ensure that the event 
// data and the event venue data are present in full.
$events = $eventbrite->get('users/me/orders/', ['expand' => 'event.venue']);

?>

The call method

The call method is the most lightweight wrapper around the Guzzle client and takes three parameters; the HTTP verb (i.e. GET, POST etc), the endpoint and an optional array config for the request that maps directly to the Guzzle request options.

<?php

use jamiehollern\eventbrite\Eventbrite;

$eventbrite = new Eventbrite('MY_OAUTH_TOKEN');

// Get all of the current users' ticket orders and ensure that the event 
// data and the event venue data are present in full.
$eventbrite->call('GET', 'users/me/orders/', ['query' => ['expand' => 'event.venue']]);

?>

Responses

Successfull requests made to the API will return an array with the following information:

  • Response code
  • Response headers
  • Response body

If the body content sent back is JSON (which is almost always will be with the Eventbrite API) then this will be decoded to a multidimensional array.

The library does this by taking a Guzzle response object and extracting the most pertinent data from it. This is useful enough for most requests but since the library is just a wrapper around Guzzle, if you wish you can request the full Guzzle response object instead by passing a false value for the parse_response parameter.

<?php

use jamiehollern\eventbrite\Eventbrite;

$eventbrite = new Eventbrite('MY_OAUTH_TOKEN');

// Make a request but instruct the call to not parse the response
// and instead return the Guzzle response object.
$eventbrite->call('GET', 'users/me/orders/', ['parse_response' => false]);

?>

If you'd like the response object but also want the usual array or don't want to modify your requests, the library stores the last request for you.

<?php

use jamiehollern\eventbrite\Eventbrite;

$eventbrite = new Eventbrite('MY_OAUTH_TOKEN');

// Make a request as normal.
$eventbrite->call('GET', 'users/me/orders/');
// Get the response object.
$last_response = $eventbrite->getLastResponse();

?>

If you need the parsed data again you can parse the last response. Be advised that the parseResponse method expects an object that implements the Guzzle ResponseInterface, which will always be a Guzzle response object in this case.

<?php

use jamiehollern\eventbrite\Eventbrite;

$eventbrite = new Eventbrite('MY_OAUTH_TOKEN');

// Make a request as normal.
$eventbrite->call('GET', 'users/me/orders/');
// Get the response object.
$last_response = $eventbrite->getLastResponse();
// Parse the response.
$parsed_response = $eventbrite->parseResponse($last_response);

?>

FAQ

  • My calls aren't working and don't seem to be calling the correct endpoint. What's wrong? Make sure you don't put a slash / in front of your endpoint or you'll confuse Guzzle.
  • Is there more in depth documentation available? Not yet but as I develop the library I plan to write extensive documentation.
  • What is the roadmap for this library? Initially it will serve to be a lightweight abstraction around Guzzle focused on RESTful requests to the Eventbrite API but eventually the plan is to include data objects and heavier abstraction on a per endpoint basis for users who don't want to put too much effort into using the API manually. This will allow for both beginners and advanced users to find something valuable in the library.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].