Once you have decided on the name and location of thisįolder, you will need to set the TWITTER environment variable to this value. We will also assume that this folder is where you save any files containing tweets that you collect. We'll assume that this folder is called twitter-files, but you can call it anything you like. It's going to be important for NLTK programs to know where you have stored yourĬredentials. The values on the right-hand side of the '=' - that is, everything in caps - should be cut-and-pasted from the relevant API key information shown on the Twitter Keys and Access Tokens. Type the part up to and includinge the '=' symbol exactly as shown. Oauth_token_secret=YOUR ACCESS TOKEN SECRET In it, you should create which you should store in a text file with the following structure: app_key=YOUR CONSUMER KEY Make sure that this file is just a plain text file. Within this folder, use a text editor to create a new file called credentials.txt. It should look something like this, but with actual keys rather than a string of Xs:Īs you can see, this will give you four distinct keys: consumer key, consumer key secret, access token and access token secret.Ĭreate a folder named twitter-files in your home directory.
Go to the tab labeled Keys and Access Tokens. Make sure that you select Read and Write access for your application (as specified on the Permissions tab of Twitter's Application Management screen): The information that you provide for Name, Description and Website can be anything you like. You should then get sent to a screen that looks something like this:Ĭlicking on the Create New App button should take you to the following screen: These are the steps you need to carry out. Twitter also insists that you add a mobile phone number to your Twitter profile before you will be allowed to register an application. You will need to have a Twitter account before you can register.
TERMINAL DOWNLOAD TWITTER VIDEOS REGISTRATION
As long as you save your registration information correctly, you should only need to do this once, since the information should work for any NLTK code that you write. First Steps ¶Īs mentioned above, in order to collect data from Twitter, you first need to register a new application - this is Twitter's way of referring to any computer program that interacts with the Twitter API. This is made as simple as possible, but deliberately limits what you can do.
TERMINAL DOWNLOAD TWITTER VIDEOS HOW TO
Once you have got authentication sorted out, we'll show you how to use NLTK's Twitter class. Alternatively, if you just want to play around with the Twitter data that is distributed as part of NLTK, head over to the section on using the twitter-samples corpus reader. If you have already obtained Twitter API keys as part of some earlier project, storing your keys explains how to save them to a file that NLTK will be able to find. We explain what's involved in the section First Steps. When you have registered your API keys, you can store them in a file on your computer, and then use them whenever you want. Most of the tasks that you might want to carry out with 'live' Twitter data require you to authenticate your request by registering for API keys. It was written as an IPython notebook, and if you have IPython installed, you can download the source of the notebook from the NLTK GitHub repository and run the notebook in interactive mode. This document is an overview of how to use NLTK to collect and process Twitter data.