daemionfox / patreon-feed

Patreon RSS library based on Patreon's API
41 stars 6 forks source link

Patreon feed

3rd party library to pull posts from a creator's Patreon feed and generate an RSS file.

Usage

Caching

To cache any of Campaigns, Posts or Members add this:

\daemionfox\Patreon\API\Campaigns::setAllowCache(true); // Must be true to cache, default is false
\daemionfox\Patreon\API\Campaigns::setCacheDir('/path/to/cache');  // Must be set, cache will fail if not set
\daemionfox\Patreon\API\Campaigns::setCacheDir('numSeconds');  // default 14400 (4 hours)

To turn on caching across all things this will work:

\daemionfox\Patreon\API\APIAbstract::setAllowCache(true); // Must be true to cache, default is false
\daemionfox\Patreon\API\APIAbstract::setCacheDir('/path/to/cache');  // Must be set, cache will fail if not set
\daemionfox\Patreon\API\APIAbstract::setCacheDir('numSeconds');  // default 14400 (4 hours)

Data

$creator_access_token = 'sometoken_gotten_from_patreon_api_auth';
// Get Patreon posts
$patreon = \daemionfox\Patreon\API\Posts::init($creator_access_token);
$posts = $patreon->getPosts();
print_r($posts);
// Get Patreon campaign data
$patreon = \daemionfox\Patreon\API\Campaigns::init($creator_access_token);
$campaignID = $patreon->getCampaignID();
$tiers = $patreon->getTiers();
$goals = $patreon->getGoals();
// Get Patreon member data
$patreon = \daemionfox\Patreon\API\Members::init($creator_access_token);
$members = $patreon->getMembers();
print_r($members);
// Get RSS feed
$patreon = new \daemionfox\Patreon\Feed($creator_access_token);

// Optional:
$patreon->setPostLimit(20); // Sets the number of posts returned in the feed.  Default 10
$patreon->setShowPrivatePosts(true); // Decide if you want to show non-public posts in the feed

// Return the feed
$rss = $patreon->rss();

echo $rss;

Changelog

0.1
0.2
0.2.1
3.0