PHP path question? Instructions vague

Having trouble with the instructions on https://github.com/Patreon/patreon-php. I created my Client and API keys … and am trying to now integrate the PHP code into my site… The code for their example starts with…

require_once DIR.‘/vendor/autoload.php’;

That is giving me an error because the instructions don’t tell me how to modify the path (so my server doesn’t know where to look for these files). I assume I need to replace the DIR with a different directory. I checked the PHP files that they provide (GitHub - Patreon/patreon-php: Interact with the Patreon API via OAuth, but there is no vendor/autoload.php in the files.

In addition, even if these files existed … I dont know where to upload any of these files on my server … the root level of my server, the root of my site…?

If you installed the lib through composer, everything should be automatically set up already.

If you are installing it without composer, refer to the instructions to install it without composer.

The only instructions that I see for “installing” the libraries are …

### Install

`composer require patreon/patreon`

View the source on [github](https://github.com/Patreon/patreon-php)

There’s no mention of installing without composer. (note: my programming knowledge is pretty limited, and I’m unfamiliar with installing PHP libraries. I’m not even sure I’d have access to composer on my shared host’s environment).

It seems that support is very limited for Patreon. Anyone have any other alternatives they recommend?

You should be able to use the library by directly including the necessary files after ftping them. However, that does require programming knowledge and you would need to get help if you dont know how to do it. Without it, you wouldnt be able to use a library anyway.

A better option for you would be to use a WordPress site and install the WordPress plugin. It wouldnt require any programming knowledge to install and maintain.

Just “uploading the files” doesn’t work. BUT, I did have my webhost install the libraries, and it looks like they are working fine now…

Does anyone know a simple PHP conditional statement to show contents only IF a user is logged in through patreon?

For example:

<?php 

if($patreonloggedin == TRUE && $patreontier=="1") {

     // Show this content

} else {

     // Show "go login" statement

}

?>

Try to read the examples in the php library:

Yeah, there’s no conditionals for “logged in users” in there … There are a ton of variables … but the examples don’t specify which variable or what values constitute “logged in”.

And if I try and echo out these variables in a PHP file (to see what their contents are), almost all of them come up empty (and I know it’s linking to my patreon, because the link one of the examples shows points me onto my patreon page).

Yeah, there’s no conditionals for “logged in users” in there

Thats not correct.

This example demonstrates how to implement log in via Patreon. At the moment you have an access token, it means that the user has Patreon authorized. At this point you would need to log that user into your own website system in however way your system does it.

And the above example demonstrates how to check for member details that could be used to implement member-only features.

It may be easier for you to ask whomever developed your website for you to implement it or get someone with more experience in PHP to help.

So, by that logic, couldn’t you get the member details … such as, what membership tier they have (I’m not sure how to call that variable based on the example above) … and then do a simple conditional based on that?

Yes, it should bring anything that is needed. Just var_dump the return once and identify what fields you need from the info. Then you should be able to use those fields over the current_user variable.

I ran the user_details_and_patronage.php on my server… and echo’d out all the variables. Most of the variabales that the example document has come up empty (I dont see any mention of this issue in the documentation or the examples). I thought it would return all my information…

<!-- 
api_client: 
Patreon\API Object
(
    [access_token:Patreon\API:private] => 
    [api_endpoint] => https://www.patreon.com/api/oauth2/v2/
    [api_request_method] => GET
    [curl_postfields] => 
    [api_return_format] => array
)
 -->

<!-- patron_response: -->

<!-- email: { -->

<!-- first_name: { -->

<!-- last_name: { -->

<!-- full_name: { -->

<!-- etc... -->

It’s not fetching the user information. And the line below doesn’t seem to be doing anything…

$api_client = new API($access_token);

$access_token has no value before or after that line. Should that be declared or pulled from elsewhere? (cause that’s not working)

You should have logged the user in per the user login example and then save that token somewhere. Then you can use that token in that example to get the info.

I decided to not use Patreon. Spent the last couple weeks trying to set this up, but I’m just not getting the support I need. Instead, I just setup my own member section and shop on my site, and decided to use PayPal to manage my subscriptions.