Twitter RSS Feeds

Support requests, bug reports, etc. go here. Dedicated servers / VDS hosting only
jdelamater99
Bear Rating Master
Bear Rating Master
Posts: 109
Joined: 11 Apr 2013, 17:45

Twitter RSS Feeds

Postby jdelamater99 » 12 Jun 2013, 17:00

If you are using the v1 Twitter API to pull in user feeds, you'll notice that it has stopped working. This is because Twitter has turned off the v1 API, which breaks RSS/ATOM feeds. Version 1.1 of the API doesn't support RSS at all.

api.twitter.com/1/statuses/user_timeline.rss?screen_name=XXXXXX <--- this no longer works

The solution isn't hard, but it will take a bit of work.

First, head to https://dev.twitter.com, sign in, and authorize the dev app for your account.
Once you are signed in, create a new app at https://dev.twitter.com/apps

The only thing you actually to do here, is fill out the required fields; App Name, App Description, and Website (I used the URL for my TT-RSS install). Then mark that you've read the TOS, fill in the annoying CAPTCHA, and hit the Create App button.

You'll now be at a page with OAuth settings. At the bottom of the page, there is a button for creating an access token. Do that, and the page will refresh with the access tokens at the bottom of the page. If they don't appear initially, you may have to refresh the page again. thanks cqrt!

The things you'll need from this page are Consumer key, Consumer secret, Access token, and Access token secret.

Now, fire up your favorite text editor, and paste the following code, placing your newly created token/key/secrets where appropriate, and a few lines below that, your twitter username as a fallback incase it isn't passed in for whatever reason. Save the file and upload it to your webhost or whereever you are running tt-rss from.

Now, in TT-RSS, edit the now broken twitter feeds, and replace the feed URL with the location you installed the twitter parser to, and pass it screen_name and count variables.

your_URL_here/path_to_twitter_parser?screen_name=XXXXXX&count=YYYYYY

For example, I named my file index.php, and put it in a TWIT folder, so I access it
http://my_host/TWIT/?screen_name=Jalopnik&count=20


Now on GitHub. Grab the latest version there.
https://github.com/jdelamater99/Twitter-RSS-Parser
Last edited by jdelamater99 on 19 Jun 2013, 08:08, edited 12 times in total.

jdelamater99
Bear Rating Master
Bear Rating Master
Posts: 109
Joined: 11 Apr 2013, 17:45

Re: Twitter RSS Feeds

Postby jdelamater99 » 12 Jun 2013, 17:04

The majority of the code was found on StackOverflow.com, but I did modify it a bit to accept URL passed variables, as well as doing the RSS feed parsing, so if anyone sees anything that needs to be addressed, or finds any bugs, let me know.

User avatar
auggy
Bear Rating Trainee
Bear Rating Trainee
Posts: 14
Joined: 16 Mar 2013, 21:17

Re: Twitter RSS Feeds

Postby auggy » 12 Jun 2013, 17:06

This works fantastic.
Last edited by auggy on 12 Jun 2013, 17:26, edited 1 time in total.

jdelamater99
Bear Rating Master
Bear Rating Master
Posts: 109
Joined: 11 Apr 2013, 17:45

Re: Twitter RSS Feeds

Postby jdelamater99 » 12 Jun 2013, 17:16

Mine is working for several twitter feeds. The only difference that I can see in TT-RSS is the oldtwitter version put the screen name before the message, and I removed that so it's a little cleaner. The difference in the examples below is the old way starts the message with "briankrebs: ".
Attachments
Captured at 2013-06-12 at 9.13.49 AM.JPEG
New JSON parser
Captured at 2013-06-12 at 9.13.49 AM.JPEG (39.7 KiB) Viewed 14235 times
Captured at 2013-06-12 at 9.13.23 AM.JPEG
Old Twitter Feed
Captured at 2013-06-12 at 9.13.23 AM.JPEG (38.26 KiB) Viewed 14235 times

User avatar
auggy
Bear Rating Trainee
Bear Rating Trainee
Posts: 14
Joined: 16 Mar 2013, 21:17

Re: Twitter RSS Feeds

Postby auggy » 12 Jun 2013, 17:31


jdelamater99
Bear Rating Master
Bear Rating Master
Posts: 109
Joined: 11 Apr 2013, 17:45

Re: Twitter RSS Feeds

Postby jdelamater99 » 12 Jun 2013, 17:40


jdelamater99
Bear Rating Master
Bear Rating Master
Posts: 109
Joined: 11 Apr 2013, 17:45

Re: Twitter RSS Feeds

Postby jdelamater99 » 12 Jun 2013, 17:45

Attachments
Captured at 2013-06-12 at 9.42.52 AM.JPEG
Captured at 2013-06-12 at 9.42.52 AM.JPEG (43.36 KiB) Viewed 14198 times

cqrt
Bear Rating Disaster
Bear Rating Disaster
Posts: 70
Joined: 05 Apr 2013, 00:37

Re: Twitter RSS Feeds

Postby cqrt » 12 Jun 2013, 18:09

Nice. Love this.

cqrt
Bear Rating Disaster
Bear Rating Disaster
Posts: 70
Joined: 05 Apr 2013, 00:37

Re: Twitter RSS Feeds

Postby cqrt » 12 Jun 2013, 18:41


jdelamater99
Bear Rating Master
Bear Rating Master
Posts: 109
Joined: 11 Apr 2013, 17:45

Re: Twitter RSS Feeds

Postby jdelamater99 » 12 Jun 2013, 18:56


cqrt
Bear Rating Disaster
Bear Rating Disaster
Posts: 70
Joined: 05 Apr 2013, 00:37

Re: Twitter RSS Feeds

Postby cqrt » 12 Jun 2013, 20:22

Hmm, having firewall issues. I have my ttrss instance locked down and I'm struggling to find the right port/ip combination to subscribe and update the twitter feed (28 connect() timed out!). At the moment I've temporarily enabled incoming port 443 0.0.0.0/0 in my firewall for it to work. I've tried 199.59.0.0/16 (twitter.com), 199.16.156.0/24 (api.twitter.com).

Any other suggestions?

jdelamater99
Bear Rating Master
Bear Rating Master
Posts: 109
Joined: 11 Apr 2013, 17:45

Re: Twitter RSS Feeds

Postby jdelamater99 » 12 Jun 2013, 20:40

Hmm, nope. I am using a hosting provider, instead of running locally, so I didn't have any of those issues. I just had a quick look around the twitter dev forums, and they won't give out IPs, since they apparently change them constantly. One thing that I did find was that it operates on port 80, which is a little unusual since it uses https.
https://dev.twitter.com/discussions/4036

virgo
Bear Rating Trainee
Bear Rating Trainee
Posts: 37
Joined: 12 Jun 2013, 22:14

Re: Twitter RSS Feeds

Postby virgo » 12 Jun 2013, 22:18

It does have a disadvantage of requiring a Twitter account
Anyway, at least in my installation there are problems with Twitter id's... They end up in the feed as floating point values. With php 5.4 it should be possible to use
json_decode($json, true, 512, JSON_BIGINT_AS_STRING);
With 5.3
ini_set('precision', 20);
also helped.

jdelamater99
Bear Rating Master
Bear Rating Master
Posts: 109
Joined: 11 Apr 2013, 17:45

Re: Twitter RSS Feeds

Postby jdelamater99 » 12 Jun 2013, 23:36

That's true, it does require having a twitter account, but you could aways just setup a dummy account that is never used.

I wonder why your install isn't doing that and mine isn't. Unless the precision is already set to a sufficiently large value in mine. I'll have to investigate that. (just checked, my precision is set to 14)
Anyways, does using strval() work for you?

strval($twitter_data[$i]['id'])

If so, I'll update the code to use that.
Last edited by jdelamater99 on 12 Jun 2013, 23:40, edited 1 time in total.

cqrt
Bear Rating Disaster
Bear Rating Disaster
Posts: 70
Joined: 05 Apr 2013, 00:37

Re: Twitter RSS Feeds

Postby cqrt » 12 Jun 2013, 23:40



Return to “Support”

Who is online

Users browsing this forum: No registered users and 12 guests