Issues accessing basic member info in V2

Hello fellow devs. I’ve built a “credits” end card for my YouTube channel using V1 of the API… but I was reading about some of the info that’s available (specifically campaign_lifetime_support_cents and pledge_cadence) that I had ideas on some awesome stuff I could do…

So I set about upgrading to V2, but soon realized I was missing a step somewhere and couldn’t find any info to help resolve my issues.

I’m writing this in PHP and I have run composer require patreon\patreon. I successfully get a list of Patrons after running fetch_page_of_members_from_campaign and I loop through these results running fetch_member_details on each user… however the details I get back seem incomplete:

{
        "data": {
            "attributes": [],
            "id": "<uuid>",
            "relationships": {
                "address": {
                    "data": null
                },
                "campaign": {
                    "data": {
                        "id": "<id>",
                        "type": "campaign"
                    },
                    "links": {
                        "related": "https:\/\/www.patreon.com\/api\/oauth2\/v2\/campaigns\/<id>"
                    }
                },
                "currently_entitled_tiers": {
                    "data": []
                },
                "user": {
                    "data": {
                        "id": "<id>",
                        "type": "user"
                    },
                    "links": {
                        "related": "https:\/\/www.patreon.com\/api\/oauth2\/v2\/user\/<id>"
                    }
                }
            },
            "type": "member"
        },
        "included": [
            {
                "attributes": [],
                "id": "<id>",
                "type": "campaign"
            },
            {
                "attributes": [],
                "id": "<id>",
                "type": "user"
            }
        ],
        "links": {
            "self": "https:\/\/www.patreon.com\/api\/oauth2\/v2\/members\/<uuid>"
        }
    },

I can’t seem to find any relevant member data and (even more worrisome), running this function takes literal minutes for my campaign’s some 460 patrons.

I want to get the member’s info including their name, lifetime pledges, start date, current pledge status, number of post likes, my notes about the patron… but I’ve got no idea what am I supposed to do to get that info! Any help would be greatly appreciated!

I actually figured this out after looking at the URL encoding on this page. API Reference

I then modified fetch_member_details in API.php to build the query like so:

$fields = [
	"fields" => [
		"member" => implode(",",[
			"campaign_lifetime_support_cents",
			"currently_entitled_amount_cents",
			"last_charge_date",
			"lifetime_support_cents",
			"note",
			"patron_status",
			"pledge_cadence",
			"pledge_relationship_start",
		]),
		"user" => implode(",",[
			"thumb_url",
			"image_url",
			"full_name",
		])
	],
	"include" => implode(",",[
		"address",
		"campaign",
		"user",
		"currently_entitled_tiers"
	])
];

$query = http_build_query($fields);

return $this->get_data("members/{$member_id}?$query");

And this returns the requested data that I’m looking for. You add field names to the $fields[{key}], using the field names in the APIv2 Resources shown here: API Reference

Figuring this out was not clear at all in the documentation, but I’ve got it sorted now. I’m leaving this comment here so I can hopefully help other folks who are struggling with the same issue!

1 Like

The package at composer should be old, 0.x version if you install it from composer that way. 1.0 version was published, but separately from old one.

Best route would be to use the repo available at github: