patreon-php icon indicating copy to clipboard operation
patreon-php copied to clipboard

Retrieve more detailed data on goals and tiers

Open Number0131 opened this issue 3 years ago • 1 comments

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.

Number0131 avatar Aug 16 '20 02:08 Number0131

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.

codebard avatar Aug 26 '20 14:08 codebard