Twitter Tweets to RSS Feed, Abiding by the Twitter Rules, OAuth, PHP, Apps Engine Are Used

Introduction: Twitter Tweets to RSS Feed, Abiding by the Twitter Rules, OAuth, PHP, Apps Engine Are Used

You may have enjoyed the RSS feeds Twitter offered some time ago, but they went away March of 2013. In September of 2012 Twitter unveiled version 1.1 of its API. Twitter now offers up data in the JASON format, and requires you to create an app and register it to get the data, you can't use a 3rd party to do this for you. There are 3rd party apps that spring up and are shut down (like a Whack-a-Mole game)... so in this instructable, I hope to walk you through the process of setting up your own app, and get those tweets flowing again in RSS. This is a very simple system that will allow you to get tweets from one account (any one you pick), you can also set how many tweets are returned from the account (always from the latest tweets down).

We will walk through the whole process: 1. Creating a Gmail account, you will need a phone number that can be associated with the account. 2. Creating a Twitter account, you will need to have your email account so you can verify it. 3. Loading Notepad++, and Python 2.7.X (tools to modify the code, provided, and run the App Engine Launcher), 4. Create an app in Twitter, and an app in Google's App Engine. 5. Information on using Twitter logo to keep your efforts in line with the Twitter T&C's (must be displayed on the page with the Tweets).

I assume you are not a programmer, but know your way around your computer!

So here we go!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Get a Google Gmail Account, and Verify It.

First things first, go to and click on "create an account" at the bottom of the page. Fill out the form, pick your password carefully! Do the captcha and you are good.
Log in to the gmail account and in the upper right you will see your email address, click on the drop down arrow, and select Account (you will see “Privacy” just to the right of the word Account).
Select “Security,” then select in the Account permissions area “Access for less secure apps” setting, Enabled.

Now on to Twitter.

Step 2: Create a Twitter Account.

Go to and click on "Sign up for Twitter." Then fill out the form. I unchecked the two boxes at the end, as I didn't want to stay signed in, and I didn't want Twitter to know my browsing habits.

Click "Create My Account"
Now you have to do a little training with Twitter, they want you to add friends and get tweet from celebrities, add a photo etc.

Then you need to check your Gmail account and under the "Social" tab, you will find an email from Twitter, click on it to validate the account.

Step 3: Upload and Install Python 2.7.x Programming Language

Google is a Python shop, meaning their programmers do a lot of development in Python (a great programming language for beginners and pros' alike.

So to use some of their tools, like Apps Engine Launcher, we are going to need to install Python version 2.7.X (the "X" is for whatever version is available).

Go to

Double Click the Python 2.7.X version (currently 2.7.6) for windows installer, it will download (in Chrome it downloads in the lower left of the browser, Firefox has the green arrow in the upper right of the browser window), if you have a Mac or Linux box, those downloads are further down on the page.

Once it is downloaded, double click on the installer file, and run it. Leave everything in default position, install for all users, and the default install place (C:\Python27\), click next.....

Finish the install and we are ready for the next item.

Step 4: Installing Notepad++ to Edit the Programs

We need to edit some code (you have no worries, we will not be writing code). A great tool to edit code is NotePad++

Go to
Click on the download tab, then install it by double clicking on the download, say Yes to the install, hit OK if English is your choice of language, next, agree to T&C's, leave the install on the default location and hit next, leave the default install options (I just had the "create Shortcut on Desktop" selected), hit install. Un-check run now and Finish.

Step 5: Create Your Twitter App, and Get the Codes Needed for the Google App Engine Launcher

While signed in to your Twitter account, open a new browser tab and go to:

Click on create a new app.

Now fill in the form, pick a name for your app (it can be anything), and a description, you must use a full URL for the web site, the only thing you must get exactly right is the call back:

The rest is up to you... Now scroll down and agree to the T&C's and create the app.

Now click on the API Keys tab, here we need the API key and API secret. Just leave this web page open, we will come back and cut and paste them into the index.php code (coming up).

Step 6: Creating the Google App Engine App and Getting the Launcher Setup.

Sign in to your Gmail account and go to:

Not so fast, you may have to connect your phone with your Gmail account, (Google will call you or text you a number, enter it in the box and you are now ready to move forward).

Now fill out the form. Give your Google App a name, possibly the same name you used for the Twitter App, but all in lower case and no spaces. Check Availability, if it isn't used you are good to go, otherwise change the name till you get one to register. You need to remember this URL: you will get your tweets here soon enough... Finish the form, give your app a Title (I just left the "Open to all" selected). Now agree to the terms and create your app (it is now registered).

Step 7: Get the Code Ready, Add the API Key and Secrets

Here we go (read this, the first paragraph before you do anything), copy and paste the code below into a new NotePad++ file. Do that by clicking in the first line, then shift clicking the last line, to highlight the code (look for the line that says" ---copy everything below this line to the bottom of the page---"), then ctrl+c to copy it all and then open a new file in Notepad++ (All Programs, Notepad++, then click on Notepad++ to open the editor, ctrl+n opens a new file, now ctrl+v to past the code in to a new NotePad++ document. Change the "YOURAPIKEY" and the "YOURAPISECRET" to the API Key and API Secret you got from Twitter. Make sure you don't delete the "." periods at the end of YourAPIKEY and the beginning of YOURAPISECRET.... you have to be very careful, to only add your stuff and not change the program. The area, where you select, will turn green (in notepad++) when you have just the "YOURAPIKEY" selected to paste in your key, replacing YOURAPIKEY with the one you got from Twitter; same with the secret. These are only in the one spot at the top of this file, on line two. The line with php will be the first line in the file. Save the file in a folder and call it main.php

-------copy everything below this line to the bottom of the page-----

$encodedAccessToken = base64_encode('YOURAPIKEY'.':'.'YOURAPISECRET');    

//Setup the stream context options and create the stream to POST to twitter, added "'" around APIKey and APISecret in case they have a number at the beginning or end

    $options = array(
        'http' => array(
            'method' => 'POST',
            'header' => 'Authorization: Basic '.$encodedAccessToken,
            'content' => 'grant_type=client_credentials',
    $context  = stream_context_create($options);
    $result = json_decode(@file_get_contents('', false, $context));
    if(isset($result->token_type) && $result->token_type == 'bearer')
        $twitter_bearer_access_token = $result->access_token;
        //something broke
        $twitter_bearer_access_token = false;
$data = array('screen_name' => $_GET["name"], 'count' => $_GET["count"]);
$data = http_build_query($data);
$context2 =
			'method' => 'GET',
			'header' => 'Authorization: Bearer '.$twitter_bearer_access_token,
$context2 = stream_context_create($context2);
$json = file_get_contents(''.$GET["name"].'&count='.$GET["count"], fasle, $context2);

$return = json_decode($json);


<rss version="2.0" xmlns:atom="">
		<title><?php echo 'Twitter RSS converter'; ?></title>
		<link><?php echo ''; ?></link>
	<?php foreach ($return as $line) { ?>
		<title><?php echo htmlspecialchars(htmlspecialchars_decode($line->user->name.": ".strip_tags($line->text))); ?></title>
		<user><?php echo htmlspecialchars('@'.$_GET["name"]);?></user>
		<description><?php echo htmlspecialchars(htmlspecialchars_decode(strip_tags($line->text))); ?></description> 
		<guid><?php echo htmlspecialchars("".$line->user->screen_name."/statuses/".$line->id_str); ?></guid>
		<link><?php echo htmlspecialchars("".$line->user->screen_name."/statuses/".$line->id_str); ?></link>
	<?php } ?>

Step 8: Download and Install the Google App Engine Launcher

Open the File menu and create a new application. In the popup add a new application, enter the Google App name we created earlier, this could be different from the Twitter App name we used. Enter the Google App name, then browse to the parent directory we save the index.php and app.yaml files in. Next select PHP in the run time drop down menu. Then hit create.

Now you will see the app Google App Launcher, the top and only one... click on it. Now Deploy

Go to: Download the Google App engine SDK for PHP (you pick the operating system)

After it downloads, double click on it and install it (everything default).

Launch Google App Engine Launcher. You will need the name of the Google App you created in the app before.

File, Create New Application

Enter the name you created in the Google App Engine step (without the, just the app name)

Browse to the directory you want the code setup in (it will create a sub directory)

Select the Runtime, we are using PHP, Leave the Port and Admin Port unchanged

Click on the Create button

Test the temporary app code

Click on the app name (below) to select it

Click on the run button (big green arrow), and wait for the mouse to stop spinning (about a minute)

Click on the Browser button, if everything is working so far you will get a new browser window with “Hello world!” in the window.

Stop the test code by hitting the “stop” button

Now you need to replace main.php in the directory you selected for your code setup, you must go in to the new subdirectory (it has the same name as your application). You will find the main.php program you need to replace (the Hello World code) with the main.php you created and put your API Key and Secret in..

After you replace the main.php, go back into google app engine launcher, and reselect the application and Run it. After the mouse stops spinning (about a minute), click on the Browse button. You should get “No source given” as the output in the browser window that opens up. Awesome!

Stop the app

Click on Deploy

Enter your gmail account user name and password

Wait for it to successfully deploy (you are looking for a code 0)

Close the Google App Engine Launcher, your app is ready!

Step 9: How to Run Your New App, and Twitter T&C's, Display the Logo!

WOW... 10 steps to tweeting with RSS feeds.  You can use the app to get RSS feeds from any Twitter account, but others can't (shouldn't) use your app, as Twitter doesn't let (want) a 3rd Party using the app you created, that is registered to you...  To be in compliance you have to create your own app and register it and use the Twitter logo (in your display of the RSS feeds) to abide by the T&C's of Twitter (I am not a lawyer, so take no advice from me LOL).

To use your new app, simply enter the URL with these additions: ?name=TwitterID&count=3


After the ?name= you enter the Twitter ID of the person's tweets you want to see, in this case National Public Broadcasting's show All Things Considered "npratc".  After the &count= you enter the number of tweets (most recent ones first), you want to be in the feed, in this case 10.

Last make sure you use the Twitter Logo.... when displaying the feeds.  It is all part of the T&Cs you agreed to, here is a resource to get your twitter bird:

Have Fun!
Make it a Tremendous Day tweeting via RSS feeds.

Step 10: Good Luck

Be the First to Share


    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    9 Discussions


    5 years ago on Introduction

    Python 2.7.9 doesn't work with Google App Engine (at least this week LOL), you should get 2.7.8, I know it works.


    Reply 5 years ago on Introduction

    Casey.lisak, I haven't seen this issue....


    5 years ago on Step 8

    The App Engine creates a new folder and puts a app.yaml file in it that is set up for a main.php it also creates a program main.php (this generates the "Hello World" message. I would copy you program in with the name main.php (not Index.php) to the new folder. In the App Engine Launcher, click on your program and stop it. Then re run it and all should be good (you will get an error, as you don't have the command line arguments on the URL, but we will at them in the next step. If you get an error on line 2, you need to add single quotes around your API Secret and API Key.

    Mr Sparkle
    Mr Sparkle

    5 years ago on Introduction

    Your guide is quite great and awesome. I have one question though, if i were to add a search function that takes a query as a parameter, how can i do it using the getjson method you have in the library?. keeping in mind that i want to search the public tweets and not a particular user.


    5 years ago on Step 8

    I have had some trouble with this step. When you deploy the app it seems
    to create a sub folder, the Icon and other stuff, but it names the file
    main.php. If you try step 10 and you get "Hello World", you need to
    copy the code (index.php) into the new subfolder on your computer with
    the Main.php (open main.php up and change the hello world code to the
    php code we cut and pasted earlier). It can take some futsing around,
    but you will get it working.


    5 years ago on Step 7

    Changed up the PHP code to add the "@" in front of the twitter user name. 4/6/2014


    5 years ago on Step 4

    I don't have a mac but saw that TextWrangler is free and works... it is available in the Mac App Store. Others include Exchanger XML Lite, Morphon, oXygen. Check them out an let us know which you like best on the Mac to edit XML, PHP etc...