PHP code example of daemionfox / patreon-feed

1. Go to this page and download the library: Download daemionfox/patreon-feed library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

daemionfox / patreon-feed example snippets


\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)
 
\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)

$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;