My Patreon account is pledging to one creator so far, but the \current_user
API response for data.relationships.pledges.data
is an empty array (same as in the API doc example).
Question: are pledges only “official” after a payment cycle happened? Or are the pledges hidden because my creator API account doesn’t have the necessary scope to access to the campaign I pledge to?
I’m working on integrating the API into my web app, for now it should work as a login-like mechanism to unlock access for potential contributors. Would be good to have an example on how to check whether the authorized Patreon user is pledging to specific campaigns or not.
Cheers
1 Like
I believe it’s the latter. If you want access to pledges that aren’t to your own campaign, you need a client with multi creator privalages.
Pledges get added to the list when they are pledged (which also updates the created_at field if it’s a new pledge and NOT updating the pledge amount). They also (I believe) get removed from the pledge list when they delete their pledge, even if they’ve payed for the month.
With the multi campaign, however, you get ALL the users pledges, not just the one to your campaign. So basically you need to cycle through all the returned pledges and find the correct one. This is how I handle checking whether or not a user is authorized with a multi campaign (PHP, with some custom object wrappers, but you get the idea):
$cid = 12345; //campaign id
$response = $this->api()->fetch_user('pledges.campaign.null',$fieldsets);
$pledge = null;
foreach($response->data->pledges as $pid){
$pledge = $response->find('pledge',$pid->id);
if ($pledge->campaign->id == $cid) break;
$pledge = null;
}
return $pledge;
1 Like