I want to set up content on my site to only be available to certain Tiers. Therefore, when creating the content, I want to list off all available Tiers, allowing the content creator to (on my site) select which Tier will have access to the content. Then, users will be checked for tier when trying to access the content, only being given permission if they are of the correct tier.
( [tier] is urlencoded above, it doesnt show in the forum. )
…properly brings tier title and description fields:
[1] => Array
(
[attributes] => Array
(
[description] => Receive a Patron Badge for your CodeBard Site and Forum Profile. Your contribution will also back the free plugins & software you are using!
[title] => Minstrel
)
[id] => 8898989898938398398989
[type] => tier
)
[2] => Array
(
[attributes] => Array
(
[description] => We will list a site URL you give us as a sponsor in our sponsors page at CodeBard.com You will also receive all of the earlier rewards!
[title] => Poet
)
[id] => 0909039408989898989899
[type] => tier
)
[3] => Array
(
[attributes] => Array
(
[description] => Receive premium priority support for a free plugin/software of your choosing from CodeBard. You will also receive all of the earlier rewards!
[title] =>
)
[id] => 989898989898989898934
[type] => tier
) (.... blah blah blah - after this it shows other tiers .....)
Modifying fetch_campaign_details in API.php to include the tier name and desc:
public function fetch_campaign_details($campaign_id) {
// Fetches details about a campaign - the membership tiers, benefits, creator and goals. Requires the current user to be creator of the campaign or requires a creator access token
return $this->get_data("campaigns/{$campaign_id}?include=benefits,creator,goals,tiers&fields".urlencode("[tier]")."=title,description");}
You can use the below example i used (as index.php)
<?php
require_once __DIR__.'/src/API.php';
require_once __DIR__.'/src/OAuth.php';
use Patreon\API;
use Patreon\OAuth;
// This example shows you how to create a webhook at Patreon API to notify you when you have any member changes in your campaign
// Create a client first, using your creator's access token
$api_client = new API('CREATORACCESSTOKENHERE');
// If you dont know the campaign id you are targeting already, fetch your campaigns and get the id for the campaign you need. If you already know your campaign id, just skip this part
$campaigns_response = $api_client->fetch_campaigns();
// Get the campaign id
$campaign_id = $campaigns_response['data'][0]['id'];
$response = $api_client->fetch_campaign_details($campaign_id);
echo '<pre>';
print_r($response);
echo '</pre>';
// If all went well, you will receive a response as depicted in the API documentation here
// https://docs.patreon.com/#triggers-v2
// Except it is decoded as an array - or whatever format you set the API client to decode returns in
I just cloned the github repo via ssh to the webroot by using the . to tell github to put the lib in the webroot
Just the codebase (ftp) where the setup is would be enough. Where you set up the php lib from github. also one creator access key that is fresh and valid (v2 key for v2 endpoint, v1 key for v1 endpoint).
As i mentioned, i can give you a disposable ftp to set up your environment there if you wish as well.
I develop Patreon’s WP plugin as a contractor. Im not an employee evidently, however i have WP plugin’s development and support responsibilities as well as troubleshooting major issues with PHP library.
You can create a totally new dud creator account, and create api client for that and use those in the test installation if you wish. And you can use the disposable domain and ftp installation i am going to give you. Either works.
If you do that, just make sure to create your tiers exactly like you did in your real creator account.
I appreciate your help, but the API is clearly broken. I’ve tested it with my code - and I’m a developer of nearly 20 years, and have integrated with multiple APIs, including pretty much every major one out there, as well as built and maintained APIs, including JSONAPI. I’m confident in my code, and the code you provided me was entirely fine, and using the master branch of the Github library. This isn’t a code problem. It’s a problem with the API.
I really do appreciate your help, but I’ve wasted enough time debugging their broken API. If they can’t even be bothered to reply to support requests, Patreon is a waste of time. What happens if/when something goes wrong?
Everything I can see from how this API is managed shows me that Patreon is not a service I can recommend to clients with good conscience moving forward. The Composer installation provided on the API documentation as being the library to use is outdated by a year. Requests to their support go entirely ignored. The API literally does not work the way it’s supposed to. And they cannot even be bothered to have their people reply on the forums that are built around their product.
It’s an extremely unprofessional, poorly maintained system, and I worry that if something goes wrong, Patreon will not support my clients properly.
I appreciate your help, but the API is clearly broken
Im able to use the api with the exact call you want to make work, without any problems. Along with the same call working in WP plugin in 2000+ installations across the internet which collectively serve multiple millions of visitors per month, as of this very moment.
This signifies one of two things:
Either your installation environment has some issue causing this call to not succeed (low chance, but possibility exists)
Or your specific Patreon account has an issue which prevents the api from returning the correct data
So basically that call works for practically everyone else but not your account. That is what we need to debug.
That is why i want to replicate your situation in a new installation environment and test if your account specifically has issues.
I gave you the exact API call I made. I understand you are an external developer, not one of their people who has access to the internals of the system. There is a limit to the support you can provide externally.
A proper support team will take the API call I made, and use their internal systems to make that call and debug the issue backwards from there. This is not something you are able to do without internal access to their servers.
So it’s not that I’m not willing to cooperate, it’s that I’ve already wasted hours on this, and trying to hack together some replication externally, when the proper solution is for the Patreon team to investigate this bug internally, just isn’t worth my time.
Again, I appreciate your help, but this is a problem with Patreon’s internals.
Making such a statement despite the call works for everyone else would be inaccurate.
…
If you provide me your valid creator access token via the forum DM to test it on my installation, we can confirm this in 5 minutes.You can refresh the access token later.
Thank you to Codebard for working through the situation with me. It was in fact a bad call in my code, calling json_debug() with the second argument as TRUE, which was stripping out some of the response - including Tier information.