daemionfox / patreon-feed

Patreon RSS library based on Patreon's API
41 stars 6 forks source link

Can't make it work #5

Closed leandroprz closed 5 years ago

leandroprz commented 5 years ago

Hi. I'm not sure how to use this.

Where do I need to put the code you mention in the readme file?

Thank you.

daemionfox commented 5 years ago

Hey there, what did you try? Give me some context and I'll try and help out.

leandroprz commented 5 years ago

I uploaded the folder Patreon and all the files and subfolders to my FTP.

Then I created a php file and added the code you put in the readme file, like this:

<?php
// Get Patreon posts
$patreon = new \daemionfox\Patreon\Feed("leandroprz");
$posts = $patreon->getPosts();
print_r($posts);
?>

When I try to access that php file at domain.com/phpfileicreated.php I get error 500.

daemionfox commented 5 years ago

Okay, so. I just popped this into my local server:

<?php
require_once(__DIR__ . "/../vendor/autoload.php");

// Get Patreon posts
$patreon = new \daemionfox\Patreon\Feed("leandroprz");
$posts = $patreon->getPosts();
print_r($posts);

And it responded with a lot of post data. So, my question is. Did you do your require/includes at the start? If you're using composer, you need to include vendor/autoload.php

If not, you need to include the Feed.php as well as the other files.

leandroprz commented 5 years ago

Thank you, I made a bit of progress. This is my file now:

<?php

require_once(__DIR__ . "/Patreon/PatreonRSS.php");
require_once(__DIR__ . "/Patreon/Feed.php");
require_once(__DIR__ . "/Patreon/Components/AbstractComponent.php");
require_once(__DIR__ . "/Patreon/Components/Campaign.php");
require_once(__DIR__ . "/Patreon/Components/Post.php");
require_once(__DIR__ . "/Patreon/Components/User.php");

// Get RSS feed
$patreon = new \daemionfox\Patreon\Feed("leandroprz");
$posts = $patreon->getPosts();
print_r($posts);

?>

That works perfectly. But when trying to use the RSS feed with

// Get RSS feed
$patreon = new \daemionfox\Patreon\Feed("leandroprz");
$rss = $patreon->rss();
echo $rss;

I'm getting this error:

Fatal error: Uncaught Error: Class 'LSS\Array2XML' not found in D:\Software\laragon\www\patreon\Patreon\Feed.php:170 Stack trace: #0 D:\Software\laragon\www\patreon\leandroprz.php(12): daemionfox\Patreon\Feed->rss() #1 {main} thrown in D:\Software\laragon\www\patreon\Patreon\Feed.php on line 170
daemionfox commented 5 years ago

Okay, so, at this point I think you need to check out composer at https://getcomposer.org/

This will simplify your problem a lot.

Follow the instructions for downloading composer, do a "composer init" (it will walk you through the steps), and when it comes time to define your requirements, add daemionfox/patreon-rss

After that, do a "composer install" to get everything downloaded properly.

Drop me a line at matt@rcsipublishing.com if you get stuck. I'm watching this thread but for some reason I'm not getting alerted when there's a reply.

leandroprz commented 5 years ago

I got it working! Thank you!!

daemionfox commented 5 years ago

Glad you were able to get things working. Happy coding!