The purpose of the SDK is to allow for easy access to the Skiddle API. This will allow developers to easily communicate with the Skiddle API to pull through information about events, artists and venues
The API requires PHP > 5.4.0, due to using autoloading and new array constructs. It also requires cURL to be enabled, which is normally done by default in PHP, but best to double check.
To connect to the API, TLS v1.2 or above is required. This has been supported by Curl using OpenSSL since version 1.0.1
There are a couple of ways to get the SDK integrated to your project, the easiest way is probably via composer:
"require": {
"skiddle/skiddle-php-sdk": "1.0.0"
}
You can also clone the git repository
git clone https://github.com/Skiddle/skiddle-php-sdk
Or, simply download the zip here and unzip to your project.
If using either of the last two methods, you will need to include the autoloader.php
file in your project to load everything up
Getting an API key is simple and free, simply go to https://www.skiddle.com/api/join.php to get one now
Once you have the code and an API key, you are ready to get started!!
You can view code samples in the /demo/
directory included in the repo
The first step is to simply authenticate yourself - just tell the SDK what your API Key is
try {
$session = new SkiddleSDK\SkiddleSession(['api_key'=>'APIKEYGOESHERE']);
} catch (SkiddleSDK\SkiddleException $e) {
echo $e->getMessage();
exit();
}
If you don't want to store this in your code, you can add it to your server environment as SKIDDLE_API_KEY
and the SDK will read from there.
After you have successfully authenticated yourself, you then need to pass your credentials to the revelant class that you want to use. This combines your authentication info with the endpoint necessary to make the calls.
To do this, simply call the setSession() method of the class you wish to use:
$events = new SkiddleSDK\Events;
try {
$events->setSession($session);
} catch (SkiddleSDK\SkiddleException $e) {
echo $e->getMessage();
exit();
}
You are now ready to make calls to the API. You can now technically make a call to return listings, however the Skiddle SDK allows you to easily add or remove conditions to make your query specific to your needs.
To add a condition, you just need to pass the field and value in the addCond()
method:
$events->addCond('eventcode','CLUB');
$events->addCond('ticketsavailable','1);
Likewise, to remove conditions, just use the delCond()
method, using only the field name:
$events->delCond('ticketsavailable');
Once you have built up your filter list, you can then get your listings!
$listings = $events->getListings();
foreach($listings->results as $result) {...}
For a full list of arguments you can filter by, have a look here
If you need to get a single result, you can call getListing()
, without having to build an array of arguments - just pass the relevant ID
For example:
$listing = $events->getListing(12345);
var_dump($listing);
- When querying eventcodes, try to keeo values uppercase. Passing CLUB will work, whereas passing club may return an error
- When using the minDate and maxDate conditions, timestamps need to be in either
Y-m-d
orY-m-dTH:i:s
format. - Don't like objects? You can get results in array format by passing a boolean in
getListings()
:$listings = $events->getListings(true); foreach($listings['results'] as $result) {...}
- Check back for more
This SDK is licensed under the GNU General Public License v3.0. View the license here
Got any questions, or ways to improve the SDK? Feel free to log an issue, or pull and fork as much as you want!