In connection with the updates of the twitter API from version 1.0 to version 1.1, requests to not receive the old-style RSS feeds stopped working, such as:
This is due to the end of twitter support for XML, RSS and Atom output standards. The developers commented on their motives for making such a decision with the thesis that the share of such requests is small and can be painlessly disabled for users.
')
But I am inclined to assume that there will be users who would like, nevertheless, to see such functionality. For this group and will be the story below.
This was already in the Simpsons.
There are many solutions to this problem. Probably the most adequate is to create a widget in your twitter account and then send the data to the google apps script for the subsequent formation of the RSS feed itself. This solution is described
here .
But after all, not everyone has their own Twitter account, and among those who don’t have one, there may well be those who just want to read other people's tweets.
Strictly speaking, the solution I propose below is not quite reading someone else's twitter, it’s just a search for all references to a username.
Let's start
To implement such a "reading" without authorization, there is a ready-made script written in perl, the code of which is available at
this link. It successfully interacts with twitter API 1.1 and displays search results in a convenient RSS form. In order to use it, you can copy it to any server owned by you and supporting perl as the script execution language for pages, or use an existing incarnation located at
this address.
But he is endowed with one significant drawback:
$body = "<![CDATA[" . HTML::Entities::encode_numeric($body) . "]]>";
Here, the “title” and “description” fields are encoded into special characters corresponding to the unicode table. There will be no problems with English-speaking tweets, but with Russian-speaking ones they can. If your RSS client does not support decoding such special characters, tweets will be unreadable.
If you chose to install this script on your server, it will be enough for you to simply correct one line, otherwise there are two ways to solve this problem: on the remote side and on the local software side.
I use RSS feed notifier to read RSS. He has no special character handling. Support for their processing can be added independently, because This software, for the most part, is written in python and the source code for it is available at
this address.
But in my case, it was decided to follow the path of full processing on the server side.
Without further ado, a script was written for the google apps script, which performs the task of converting coded special characters. I will give his code:
function doGet() { var response = UrlFetchApp.fetch("http://twitrss.me/twitter_user_to_rss/?user=username&fetch=Fetch+RSS").getContentText("Windows-1251"); var decode = XmlService.parse(response); var rootElement = decode.getRootElement(); var channel = rootElement.getChildren("channel"); var items = channel[0].getChildren("item"); for (var i = 0; i < items.length; i++) { var title = items[i].getChildren("title"); var description = items[i].getChildren("description"); var decode_title = new XML('<d>' + title[0].getText() + '</d>'); var decode_description = new XML('<d>' + description[0].getText() + '</d>'); title[0].setText(decode_title.toString()); description[0].setText(decode_description.toString()); } var output = XmlService.getPrettyFormat().format(decode); return ContentService.createTextOutput(output); }
In this script it is worth replacing username with the name of the user whose updates you would like to track.
The question of creating and publishing a script is not complicated, but has its own peculiarities. First, after copying the script code into a newly created document, it must be saved. Secondly, it is necessary to get rid of it so that the script will request permission for its execution, which we will later give to it (the “Run” button). Thirdly, it must be published to run from any source, incl. anonymous.
As a result, we will have a link of the form:
script.google.com/macros/s/__/exec
Great, now we have an RSS feed, where all special characters are replaced with their corresponding Unicode counterparts.
For those whose RSS client supports HTTPS on this article ends. Feed Notifier does not support HTTPS. In principle, the problem of lack of support for HTTPS can be solved by making appropriate changes to the source code. But here I went along the server-side path.
Since no sensitive information is transmitted through this channel, HTTPS traffic may well be redirected to a regular HTTP channel. For this, I used a banal web proxy. This web proxy can be passed an address for transition as a GET parameter, so I chose it.
Thus, as a result of all these manipulations, it is enough to feed the RSS link to the client:
www.webproxy.net/view?q=https://script.google.com/macros/s/__/exec
to get a fully functional version of the RSS feed updates twitter.
If you want to read more than one person, it is enough to add another script of the same content to the same document, but with a different username.
Maybe the method seems unnecessarily cumbersome, but it does not require any changes on the client side and allows you to group tapes in an arbitrary order. Plus it does not require a twitter account.
Thanks for attention!