First of all I am not a current developer, I’m an architect …
now that you’ve finished throwing fruit at me, I’m a little confused with the current PHP API library for Patreon.
Right now I’m just trying to check current data.
I’ve used the example code and my oAuth is happy and returns a callback and I get a data stream which is happily rendered into an Array.
A big Array (Patreon\JSONAPI\ResourceItem Object ( [resource_item:protected] => Art4\JsonApiClient\ResourceItem Object ( [container:protected] => Art4\JsonApiClient\Utils\DataContainer Object ( [allowed_keys:protected] => Array ( ) [data:protected] => Array ( [type] => user [id] )
However the problem comes when I get to looking at user data (and this is from the example code)
if ($user->has(‘relationships.pledges’)) {
Results in :
Notice: Undefined variable: user in /var/www/html/CDS/oauth.php on line 38
Unless I am wrong, I thought the base array types (according to the comments) were assigned automagically.
@markgoldienz your first lines made me laugh out loud - and thank you for finding that. Phew - that is frustrating, I apologize - will fix that. We need to overall audit our PHP library and example code. It’s due for some attention.
total_historical_amount_cents seems to be properly returned by api while using other libraries, so it doesnt seem to be an api problem.
the function attribute in ResourceIdentifier.php needs to return $pledge->attribute(‘total_historical_amount_cents’) when requested, using factory json api class instantiated as below
$this->resource_item = new \Art4\JsonApiClient\ResourceItem($manager, $parent); in __construct.
Dropping some var_dump to see the input variables and the json api return in __construct may help to see whats going on. Also, if the patron doesnt have any pledge history, that variable may not be returned at all. (Ie, the patron hasnt paid yet).
I’ll look into this, but i have to install the lib in a test environment myself and check it out.
Being too tired and too late here, what i typed above may not be of much help but hopefully will give you some pointers for the time being.
@markgoldienz thanks to @codebard’s help we’ve found some additional issues that seem to likely be our fault here - investigating internally. My apologies for the frustration. Our libraries need a lot of love.
However, while this works with WordPress plugin and its calls, for some reason api returns an error when you try the same thing with the PHP library. At least, in the php7 dev container i set up in docker.
You may try modifying the api class to make the call specifically as above, asking for the field and see if it returns properly.
Also you are right in that the data doesnt seem to be structured as described in the example.