I’m trying to show a Twitter feed on my site using Tweetie.js. I’ve been following this thread Best recommendation for displaying Twitter feed?
I have copy/pasted the api folder into assets, and I do have c::set('twitter.key', consumer key); c::set('twitter.secret', consumer secret); in the config.php, but nothing shows up
This is what I have in my template:
<div id="tweet">
</div>
Console errors are:
[Error] ReferenceError: Can’t find variable: require
Global Code (tweetie.js:7)
[Error] SyntaxError: Can’t create duplicate variable: ‘config’
(anonymous function)
[Error] SyntaxError: Unexpected end of script
(anonymous function) (new-alt-times:936)
Yes, I have this in my header snippet
<?= js("https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.min.js") ?>
<?= js("assets/js/tweetie.js") ?>
<?= js("assets/js/tweetie.min.js") ?>
The API folder needs to be in assets/js not just in assets. Maybe the javascript cant find the API. And your calling script twice. Delete <?= js("assets/js/tweetie.js") ?>. This is the uncompressed version that shouldnt be used in production.
The version jQuery might be too low. The demo page in the documentation file for tweetie uses jQuery 3.2.1.
Yes i noticed that to, but thats the default built into the script. you override the default path like so:
The docs for the script are not terribly good, and it seems to have changed a bit since i last used it. I got the cors issue when trying to use the api path set in the example file that comes with the script, but not locally running from the same server.
I would say thats a better way to go. From past experience Twitter likes to upset everyone occasionally by changing the way tweets can be fetched. I had to update about 20 websites a few years back because they rendered most of the JavaScript / jQuery solutions useless by requiring authentication. That was not a fun afternoon.
@texnixe So I tried your approach first to see if I could get the original plugin to work, but still nothing seems to show up? I made the plugins/tweetie folder with the structure you said and added the route in config.php, and the console isn’t showing any errors either, so I can’t really tell what’s wrong.
@jimbobrjames I’ve never used Composer so I downloaded the folder from GitHub. I did make a new twitter snippet with the code you provided, but where in the Kirby structure should I put the twitter-php-master folder? There is this error, but I don’t see the vendor/autoload.php file anywhere in the downloaded files anyway.