A PHP library for interacting with the Patreon Platform, designed to provide the easiest path for integrating Patreon into your application with a simple interface that abstracts away the underlying Patreon API.
- PHP >=7.2
- Composer
- An HTTPlug compatible client
such as
php-http/guzzle6-adapter
Patreon PHP is available on Packagist.
composer require squid/patreon php-http/guzzle6-adapter
You may swap out php-http/guzzle6-adapter
for your own
HTTPlug Compatible Client,
such as the cURL client
or the React HTTP Adapter.
After you've installed the package you're ready to instantiate a client with your access token and then request data for resources.
use Squid\Patreon\Patreon;
$patreon = new Patreon('access_token');
$campaign = $patreon->campaigns()->getMyCampaignWithPledges();
echo "Hello, {$campaign->creator->full_name}! You have {$campaign->patron_count} patrons.\n";
$campaign->pledges->each(function ($pledge) {
echo "{$pledge->patron->full_name} has been a patron since {$pledge->created_at}.\n";
});
Documentation is available covering all aspects of the library, from getting started to architecture, or you can get started by looking at some examples of how to achieve the most common integrations.
- Getting Started
- Obtaining OAuth Tokens For Patrons
- Patreon Integration Examples
- Method Documentation
- Library Architecture
A full example project that you can download and use is available at 1f991/patreon-php-example which includes:
- Display a list of Patrons
- Instantly add/delete/update patrons using Webhooks
- Allow Patrons to log in with OAuth
A demo of the example project can be found live at patreon.1f991.com where you can create a pledge and log in to see it in action.
Alternatively, smaller self-contained examples of specific implementations are available in the documentation for this project:
- Display Patron's pictures
- Create a list of your Most Valuable Patrons Email Addresses
- Delete a User's account when their Pledge is cancelled
Please visit the Patreon Developers forum with any questions you have about using this library, or the Patreon Plaform. Please report any bugs found in this library by creating a new issue. A reproduceable test case should be included where possible, otherwise a description of your problem and steps to reproduce would be very helpful.
This library has been made possible by the fantastic open source contributions of others, including...
- Yang, a JSON:API Client Library by Woohoo Labs
- HTTPlug, the HTTP client abstraction for PHP
- Collect, a split of Laravel Collections
Please reach out to Samuel Ryan via email (sryan@1f991.com) to report any security concerns you may have discovered with this library. Acknowledgement will be provided within 24 hours.
Patreon PHP is open-sourced software licensed under the MIT license.