5

I am a geography teacher and would love to map tweets in QGIS for my pupils. I followed all the instructions but it seems Twitter have changed the way they stream their tweets. I can cope with the GIS side but I am not a Twitter developer. Is there any advice you can give a very busy teacher on getting those tweets?

4

I used to do this with curl as described here, but Twitter removed basic authentication support from public streaming endpoints on June 11, 2013, so you need to use OAuth. In order to do this you need to have a Twitter account and request an application.

Below is a very simple example, written in Python using the twython library.

from twython import TwythonStreamer

# supply your OAuth values below
APP_KEY = 'xxxx' 
APP_KEY_SECRET = 'xxxx'
ACCESS_TOKEN = 'xxxx'
ACCESS_TOKEN_SECRET = 'xxxx'

class MyStreamer(TwythonStreamer):
    def on_success(self, data):
        if 'coordinates' in data:
             try:                 
                 print 'lat: ', data['coordinates']['coordinates'][0], 'lon: ', data['coordinates']['coordinates'][1],  '\n'
             except:
                  pass

    def on_error(self, status_code, data):
        print status_code, data

stream = MyStreamer(APP_KEY,
        APP_KEY_SECRET,
        ACCESS_TOKEN,
        ACCESS_TOKEN_SECRET)

stream.statuses.filter(locations='-180,-90,180,90')

If Python is not your language of choice, there are other options.

0

If you don't want to use any programming language whatsoever, you could try something like Geofeedia (see below), which would allow you to look at Twitter and other social media feeds in a geographic context. The website has a closed Beta right now, but you can apply for access.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.