Format of user ID when calling API

fetch_user() returns an eight digit number ######## as my user ID in [‘data’][‘id’]. It also returns an ID with this format: ########-####-####-####-############. This number is in: ['included']['0']['id']

When I use the long format which looks like some sort of md5 hash with the function fetch_member_details($member_id) I get a correct match. However, the user_id of ######## does not work. I have tried sending it as md5 but that doesn’t work either. Is there a way to send the user_id of ######## via fetch_member_details($member_id) by encryption or other means?

I guess I just don’t know the proper way to encode/encrypt it.

1 Like

Is this with PHP library?

Yes. I am using the official Patreon PHP library. These functions are in API.php

[data][id] should be the id you need then…

When I use [data][id] it returns: member with id ######## was not found
See the member ID in this example call

Sample response for https://www.patreon.com/api/oauth2/v2/members/03ca69c3-ebea-4b9a-8fac-e4a837873254?...

Here they are also passing a 32 character encryption (with added hyphens) of the user ID, but they do not mention how this user ID representation was derived/created.

The numeric user id you have must be used with…

/api/oauth2/v2/identity

…endpoint. There already should be an example in PHP lib?

There is an example. It says…

Member id can be acquired from fetch_page_of_members_from_campaign

That function returns the same 32 digit member_id which works with fetch_member_details but that seems to be a very long route to getting the ID you need. It sends you pages of members which you then need to loop through to find the 8 digit user_id which will then allow you get the 32 digit member_id. This method requires an additional API call as well.

I wonder if there is a method to convert the 8 digit user_id to the 32 digit member_id.

For now I will just grab ['included']['0']['id'] from the call to fetch_user(). But I am worried that, depending on the user, this data may not always be found the same column within the array.

Since both should be pointing to the same user, the actual id should work. If you experience any oddities, just post them here.