# How can I get patrons with the API?

**URL:** <https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930>\
**Category:** API Feedback\
**Created:** [August 6, 2022, 11:19am UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930 "2022-08-06T11:19:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jazrol](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jazrol](https://www.patreondevelopers.com/u/jazrol)\
**Post date:** [August 6, 2022, 11:19am UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/1 "2022-08-06T11:19:57Z")

</div>

Hi. I’m trying to implement a patron status check on my website. I want to periodically run this check via cron. The system will take a patron, then make a request to the Patreon API and check if it is an active patron. What is the best way to do this?

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [August 8, 2022, 8:46pm UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/2 "2022-08-08T20:46:36Z")

</div>

Depends. Do you need to do this live, right at the time a patron is logged into your website? Or is it a background process?

---

<div class="post-metadata">

**Author:** ![jazrol](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jazrol](https://www.patreondevelopers.com/u/jazrol)\
**Post date:** [August 8, 2022, 9:40pm UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/3 "2022-08-08T21:40:00Z")

</div>

Background process. I need up-to-date information even if the user is not logged in. I want to do this with a cron on the server (check patrons once an hour).

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [August 10, 2022, 12:18am UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/4 "2022-08-10T00:18:33Z")

</div>

If this is your campaign, just use your creator access token to pull your patrons by paginating your members list.

If this is not your campaign, then you will need to get creators to authorize your app by asking the campaigns scope during authorization. Then you can use their individual tokens to pull their individual campaigns.

---

<div class="post-metadata">

**Author:** ![jazrol](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jazrol](https://www.patreondevelopers.com/u/jazrol)\
**Post date:** [August 10, 2022, 9:15am UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/5 "2022-08-10T09:15:56Z")

</div>

Yes, this is my campaign. It turns out that I will take the token for the creator here  
[API Reference](https://docs.patreon.com/#oauth) (manually via the button)

Then save the token in the database. And then use the token to access the patrons data here

[https://docs.patreon.com/#paging-through-a-list-of-pledges](https://docs.patreon.com/#paging-through-a-list-of-pledges)

This is right?

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [August 10, 2022, 6:57pm UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/6 "2022-08-10T18:57:41Z")

</div>

Yep. That’s right. Your apps are listed in the below page:

> **[Patreon](https://www.patreon.com/portal/registration/register-clients)**
>
> Patreon is empowering a new generation of creators. 
> Support and engage with artists and creators as they live out their passions!

---

<div class="post-metadata">

**Author:** ![jazrol](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jazrol](https://www.patreondevelopers.com/u/jazrol)\
**Post date:** [October 19, 2022, 1:42pm UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/7 "2022-10-19T13:42:51Z")

</div>

I am using this library

> **[GitHub - Patreon/patreon-php: Interact with the Patreon API via OAuth](https://github.com/Patreon/patreon-php)**
>
> Interact with the Patreon API via OAuth. Contribute to Patreon/patreon-php development by creating an account on GitHub.

Is it possible to get users through it?

As for the access token. Here [Patreon](https://www.patreon.com/portal/registration/register-clients) i see Creator access token. Do I need to use it in queries for a company? I see that it is becoming obsolete, it may not be very convenient (updating manually on the server). Do I need to refresh the token programmatically? It looks bad, there are so many actions for such a simple integration:) Usually APIs work much easier.

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [October 20, 2022, 10:04pm UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/8 "2022-10-20T22:04:05Z")

</div>

Creator’s access token allows you to access all the details of your campaign, its members and their membership info without having any users to authorize your application - just like I posted in the other thread.

---

<div class="post-metadata">

**Author:** ![jazrol](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jazrol](https://www.patreondevelopers.com/u/jazrol)\
**Post date:** [October 21, 2022, 11:22am UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/9 "2022-10-21T11:22:12Z")

</div>

I am using creator’s access token from here [Patreon](https://www.patreon.com/portal/registration/register-clients) in the library. I call this way

```auto
    public function getPatrons()
    {
        $api = new API(config('patreon.access_token'));

        dd($api->fetch_campaigns());
    }

```

I’m getting null in response. What am I doing wrong? Which API class method should I use to get my company’s patrons? Thanks for the help!

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [October 24, 2022, 3:12pm UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/10 "2022-10-24T15:12:58Z")

</div>

Are you using Laravel? Try to confirm that no Laravel package interferes with the outgoing call.

---

<div class="post-metadata">

**Author:** ![jazrol](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jazrol](https://www.patreondevelopers.com/u/jazrol)\
**Post date:** [October 27, 2022, 10:21am UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/11 "2022-10-27T10:21:54Z")

</div>

Yes, I am using Laravel. How can this be checked?

---

<div class="post-metadata">

**Author:** ![jazrol](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jazrol](https://www.patreondevelopers.com/u/jazrol)\
**Post date:** [October 27, 2022, 10:26am UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/12 "2022-10-27T10:26:12Z")

</div>

I’m using the API class for authorization through Patreon. And there these classes work without problems. It turns out that no package interferes with requests. This code works:

```auto
        $patron->access_token = $access_token;
        $patron->refresh_token = $refresh_token;

        $api_client = new API($access_token);

        $api_client->api_return_format = 'object';

        $patreonUser = $api_client->fetch_user();

```

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [October 28, 2022, 8:50pm UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/13 "2022-10-28T20:50:38Z")

</div>

Can you try making the same call using the PHP library outside Laravel and see if that makes any change?

---

<div class="post-metadata">

**Author:** ![jazrol](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jazrol](https://www.patreondevelopers.com/u/jazrol)\
**Post date:** [October 29, 2022, 8:12am UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/14 "2022-10-29T08:12:53Z")

</div>

I write this in an empty PHP project and I get NULL in response

```auto
<?php

require_once __DIR__.'/vendor/autoload.php';

use Patreon\API;

$accessToken = 'token';

$response = (new API($accessToken))->fetch_campaigns();

var_dump($response);

```

Could there be something wrong with my token?

---

<div class="post-metadata">

**Author:** ![jazrol](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jazrol](https://www.patreondevelopers.com/u/jazrol)\
**Post date:** [October 29, 2022, 8:15am UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/15 "2022-10-29T08:15:31Z")

</div>

I think I understand … I’m from Russia, Patreon is blocked with us. Is it possible to make a request without blocking?

---

<div class="post-metadata">

**Author:** ![jazrol](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jazrol](https://www.patreondevelopers.com/u/jazrol)\
**Post date:** [October 31, 2022, 7:12am UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/16 "2022-10-31T07:12:00Z")

</div>

No, it turns out Patreon is not blocked in Russia. Perhaps the problem is in the token? I am using a token from my Patreon account, not after oauth authorization (as in the package example).

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [November 1, 2022, 6:35am UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/17 "2022-11-01T06:35:52Z")

</div>

You can use your creator’s access token to access your campaign and its members.

But if you are trying to access another campaign’s info, or another campaign’s patron’s info, you will need to have them authorize your app with the correct scopes (permissions) for your app. Then you can use that specific token to make a call.

Basically, make sure that the token that you are using has access to the account that you are trying to access, and it has the correct scopes to access the fields that you want.

---

<div class="post-metadata">

**Author:** ![jazrol](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jazrol](https://www.patreondevelopers.com/u/jazrol)\
**Post date:** [November 1, 2022, 8:30am UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/18 "2022-11-01T08:30:21Z")

</div>

I am using the token from here [Patreon](https://www.patreon.com/portal/registration/register-clients). I created an application where there is a token, a refresh token and a secret word. The company belongs to me and everything is done in my account. Is it that token? Is this the token I should use in the API class or some other one?

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [November 1, 2022, 11:57pm UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/19 "2022-11-01T23:57:15Z")

</div>

That depends on whether the patrons (or other creators) will log into your app and do things with your app.

If they won’t, yes, you can use the token in your account.

---

<div class="post-metadata">

**Author:** ![jazrol](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jazrol](https://www.patreondevelopers.com/u/jazrol)\
**Post date:** [November 2, 2022, 12:50pm UTC](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930/20 "2022-11-02T12:50:53Z")

</div>

This is how I use and get null in the response 🙂 This is the problem.

[Next page](https://www.patreondevelopers.com/t/how-can-i-get-patrons-with-the-api/5930.md?page=2)
