# \[SOLVED\] Cannot use object of type Art4\\JsonApiClient\\Document

**URL:** <https://www.patreondevelopers.com/t/solved-cannot-use-object-of-type-art4-jsonapiclient-document/1995>\
**Category:** Friendly Help\
**Created:** [June 26, 2019, 10:45pm UTC](https://www.patreondevelopers.com/t/solved-cannot-use-object-of-type-art4-jsonapiclient-document/1995 "2019-06-26T22:45:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thunder](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@Thunder](https://www.patreondevelopers.com/u/Thunder)\
**Post date:** [June 26, 2019, 10:45pm UTC](https://www.patreondevelopers.com/t/solved-cannot-use-object-of-type-art4-jsonapiclient-document/1995/1 "2019-06-26T22:45:42Z")

</div>

Hey I’m trying to get the user’s info so I can send it to a database for their account. I have an issue I cannot wrap my head fully around. This is my code.

```
<?php require_once '../vendor/autoload.php';

use Patreon\API;
use Patreon\OAuth;

$client_id = 'TheClientId';
$client_secret = 'TheClientSecret';
$redirect_uri = "https://redirect.com";

$access_token = "Users access token";

$api_client = new API($access_token);
$current_member = $api_client->fetch_user();

$email = $current_member['data']['attributes']['email'];?>

```

With this I get the error “Uncaught Error: Cannot use object of type Art4\JsonApiClient\Document as array” on the email line. What is the correct way to format that line so I can get the email of the 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:** [June 27, 2019, 10:46am UTC](https://www.patreondevelopers.com/t/solved-cannot-use-object-of-type-art4-jsonapiclient-document/1995/2 "2019-06-27T10:46:43Z")

</div>

If you are using the PHP lib version you got from composer, that is outdated. Please use the one at github.

The one at githup is updated for v2 api and only uses v2 api. And it has art4 lib removed. The examples there should be much more comfortable to adopt.

---

<div class="post-metadata">

**Author:** ![Thunder](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@Thunder](https://www.patreondevelopers.com/u/Thunder)\
**Post date:** [June 27, 2019, 12:45pm UTC](https://www.patreondevelopers.com/t/solved-cannot-use-object-of-type-art4-jsonapiclient-document/1995/3 "2019-06-27T12:45:59Z")

</div>

Thank you for the information, I’ll switch over to github right away, I didn’t notice at the time that the packagist version was outdated. That’ll likely fix all my issues, thank you!

---

<div class="post-metadata">

**Author:** ![Thunder](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@Thunder](https://www.patreondevelopers.com/u/Thunder)\
**Post date:** [June 27, 2019, 1:37pm UTC](https://www.patreondevelopers.com/t/solved-cannot-use-object-of-type-art4-jsonapiclient-document/1995/4 "2019-06-27T13:37:46Z")

</div>

Hmm, now I’m getting another issue with this line

```
$tokens = $oauth_client->get_tokens($_GET['code'], $redirect_uri);

```

It appears get\_tokens is undefined. I haven’t been able to spot get\_tokens in the source either, is that something I’ll have to personally define?

---

<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:** [June 27, 2019, 5:24pm UTC](https://www.patreondevelopers.com/t/solved-cannot-use-object-of-type-art4-jsonapiclient-document/1995/5 "2019-06-27T17:24:10Z")

</div>

get\_tokens is in OAuth.php. Did you include that class?

---

<div class="post-metadata">

**Author:** ![Thunder](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@Thunder](https://www.patreondevelopers.com/u/Thunder)\
**Post date:** [June 27, 2019, 5:52pm UTC](https://www.patreondevelopers.com/t/solved-cannot-use-object-of-type-art4-jsonapiclient-document/1995/6 "2019-06-27T17:52:26Z")

</div>

Ah, somehow I had missed that before while looking. I found the source of the issue, it seems I likely had messed up my composer or Patreon install due to the shuffling around as composer doesn’t hook up correctly, but including the Patreon source files directly into the problem areas solves the issue so I’ll debug what happened on my end there.

Sorry about the confusion, I just confirmed that things are working out and things are working which is exciting! I absolutely love this! Thank you again for being so helpful with my silly problems and informing me that the composer one was out of date.

---

<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:** [June 27, 2019, 6:50pm UTC](https://www.patreondevelopers.com/t/solved-cannot-use-object-of-type-art4-jsonapiclient-document/1995/7 "2019-06-27T18:50:58Z")

</div>

You can just rm -rf that subdir (if linux) and clone git repo into the same dir and that should do it… Currently this lib doesnt have any relation with composer.

---

<div class="post-metadata">

**Author:** ![Thunder](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@Thunder](https://www.patreondevelopers.com/u/Thunder)\
**Post date:** [June 28, 2019, 2:41am UTC](https://www.patreondevelopers.com/t/solved-cannot-use-object-of-type-art4-jsonapiclient-document/1995/8 "2019-06-28T02:41:55Z")

</div>

Oh gotcha. It was my first time working with this sort of thing so I followed everything to a T out of worry, so the instructions on installation to go to Packagist tripped me up, but it was a good lesson to learn to just go directly to github if possible.

Edit: Changed the title back to what it was originally so anyone else who has the same issue as me can quickly locate it.
