Noob: Accessing Tiers

Hi there.

I’m just starting out with the php API, and using the following unified example and getting the user details below I’ve managed to get it all working, but I am having issues trying to access the membership tier data, I’m struggling with the scopes.

Can anyone throw me a lifeline, I’m not a developers developer just a bit of a hack.


First, you should make sure that you are using a v2 client and you are calling a v2 endpoint with it.

The scopes - you should request them at the time which you are sending the user to Patreon to log in via Patreon.

Hey @codebard,

My client api is v1, but it seems as though I cant edit it.
Any Ideas?

Trying a v2 client and calling v2 api may provide improvement - v1 api is going to be deprecated in foreseeable future, therefore it may not be providing everything which v2 api offers.

@codebard these are the scope_parameters I am using, looking for the tiers.

$scope_parameters = ‘&scope=campaigns.members%20identity%20identity’.urlencode(’[email]’);
$include_parameters = “&include=campaign%20memberships”;

$href = ‘’ . $min_cents . ‘&client_id=’ . $client_id . $scope_parameters . $include_parameters . ‘&redirect_uri=’ . $redirect_uri;

$api_client = new API($access_token);
$current_member = $api_client->fetch_user();
$email = $current_member[‘data’][‘attributes’][‘email’];

This works, But I just cant find the currently entitled tiers…

That url looks like an authorization url. When you get the authorization token with correct scopes, you must call the api endpoint with the correct includes you desire - derived from those scopes.

So first send the user to the Patreon login to get authorization codes. Or via the pledge flow. When you get the tokens via the codes, you can call the relevant endpoint and request relevant includes.

Also, check this out:

@codebard Thank you for responding so quickly, yes that is the authorization url, it then redirects to page with this code below.

But this is where it get real confusing for me.
I don’t even know if i’m on the right path here…

$client_id = ‘my id’; // Replace with your data
$client_secret = ‘my scret’; // Replace with your data

$redirect_uri = “redirect url”;

if (isset($_GET[‘code’])) {

oauth_client = new OAuth($client_id, $client_secret);
$tokens = oauth_client->get_tokens(_GET[‘code’], $redirect_uri);
$access_token = $tokens[‘access_token’];
$refresh_token = $tokens[‘refresh_token’];

$api_client = new API($access_token);
$current_member = $api_client->fetch_user();
$email = $current_member[‘data’][‘attributes’][‘email’];
$first_name = $current_member[‘data’][‘attributes’][‘first_name’];
$last_name = $current_member[‘data’][‘attributes’][‘last_name’];



I’ve found out what I need to. I didn’t know the other fetch functions from the api… ie fetch_campaign_details etc.

Thanks for you help

1 Like