Get tier of subscription of a patron in my app

Hello,

In my app I need to differentiate users based on if they are:

  1. Subscribed to my patreon
  2. The tier they have subscribed

I’ve implemented the “log in with Patreon” button with the scope: “identity”
Then I use their access token to request (as I’ve seen on this forum multiple times and in the PHP doc):

https://www.patreon.com/api/oauth2/v2/identity?include=memberships.currently_entitled_tiers,memberships.campaign&fields[member]=currently_entitled_amount_cents,lifetime_support_cents,campaign_lifetime_support_cents,last_charge_status,patron_status,last_charge_date,pledge_relationship_start

My question est extremely simple:
Is my patreon (campaign) always the first index (index: 0) of the ‘included’ property?
If yes, then I can use to check their authorizations:

$data['included'][0]['attributes']['currently_entitled_amount_cents'];
$data['included'][0]['attributes']['patron_status'];

Or should I map over the included results and check their related campaign’s id to find my campaign?
$data['included'][0]['relationships']['campaign']['id'];

Thanks for your help!

1 Like