Dribbble API PHP Wrapper

The Dribbble API PHP Wrapper is what it says on the say. It is designed to provide easy access to Dribbble’s API in your PHP scripts and web sites.

Requirements

The Dribbble API PHP Wrapper has very modest requirements. They are:

Most Linux-based web servers have these. If not, find a new web host. I suggest Dataflame.

Using the Wrapper

You can either use the wrapper in the traditional, include-and-instantiate classes way:

<?php

require 'src/Dribbble/Dribbble.php';
require 'src/Dribbble/Exception.php';

$dribbble = new Dribbble\Dribbble();

Alternatively, you can use Composer to automatically include the wrapper in your project. Simply add the following to your composer.json file:

{
    "require": {
        "martinbean/dribbble-php": "2.2.0"
    }
}

From here, you can then start to call the methods to access the Dribbble API.

Currently, the methods contained are:

These correspond to the API methods as described on Dribbble’s API documentation page.

As per Dribbble’s documentation, some methods take an optional id parameter which can be either a player ID or alpha-numeric username; and some further methods take optional page and per_page parameters for pagination.

Responses

All responses from the Dribbble API PHP Wrapper are returned as PHP objects, so you can act on properties directly. If any errors are encountered, then a Dribbble\Exception is thrown, which can be caught in a try/catch block.

An example usage would be:

<?php

$dribbble = new Dribbble\Dribbble();

try {
    $my_shots = $dribbble->getPlayerShots('martinbean');
    foreach ($my_shots->shots as $shot) {
        echo '<li><a href="' . $shot->url . '">' . $shot->title . '</a></li>';
    }
}
catch (Dribbble\Exception $e) {
    echo $e->getCode() . ': ' . $e->getMessage();
}

This would fetch mine (martinbean) shots, but catch any exceptions should they arise.

Final notes

The Dribbble API PHP Wrapper is released under the MIT License. If you can see any room for improvement feel free to fork this repository and send a pull request.

Additionally, if you create any thing (i.e. third-party plugins) using the Dribbble API PHP Wrapper then do let me know and I’ll mention it here.