Patreon / patreon-php

Interact with the Patreon API via OAuth
Apache License 2.0
145 stars 41 forks source link

Retrieve more detailed data on goals and tiers #84

Open Number0131 opened 4 years ago

Number0131 commented 4 years ago

I managed to fetch campaign information from my account but i can't get more detailed data than this:

 [goals] => Array
                        (
                            [data] => Array
                                (
                                    [0] => Array
                                        (
                                            [id] => 12345
                                            [type] => goal
                                        )

                                    [1] => Array
                                        (
                                            [id] => 789101112
                                            [type] => goal
                                        )

                                )

                        )

Is there a way to access infromation mentioned here https://docs.patreon.com/?php#goal? Do i need a special scope maybe? Atm. i have the campaign scope.

codebard commented 4 years ago

Check out the calls which the WP plugin uses for various purposes.

https://github.com/Patreon/patreon-wordpress/blob/add_caller_to_api_call_logs/classes/patreon_api_v2.php

You can copy those calls for your app. Of course, you will need to have requested the scopes for the user tokens when doing something with a user token. Creator token should already have the scopes you need.

In your case the fetch_campaign and creator related calls should work.

/campaigns?include=goals&fields[goal]=amount_cents,title,description,created_at,reached_at,completed_percentage

The above call to a v2 endpoint with a v2 client should give you the goals.