Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Python Twitter API Help!

$
0
0
Hi, I'm still learning json and stuff like that so I need a little help.

I'm basically trying to use twitter API to visualize the tweets on my timeline.

This is my code so far:

import oauth2 as oauth
import json, pydot

# Twitter API documentation
# https://dev.twitter.com/docs/api/1.1
    
# Get access tokens from https://dev.twitter.com/docs/auth/tokens-devtwittercom    
consumer_key = 'lxtsdeIhTB7JxJZuSU99Q'
consumer_secret = '8YiCsdfT16yYGLSQlFkCDaIx9jDV2RnbU0lmFvtER8M'
access_token = '274079022-e41hZYDc7LQJ3TeM8zxzPKwx515DVxHrkpNbj3SA'
access_secret = '61mHK9SawAsqF6u89FQ2xRXFZuRFbAPPCQOMa7xG0BQ'

consumer = oauth.Consumer(key=consumer_key, secret=consumer_secret)
token = oauth.Token(key=access_token, secret=access_secret)
client = oauth.Client(consumer, token)

# Get up to 200 tweets on your own home timeline
header, response = client.request('https://api.twitter.com/1.1/statuses/home_timeline.json?count=200', method="GET")

print response

# load the response JSON string into a Python data structure??




I don't really know how to load my response JSON string into a Python data structure (txt?) so I can use it create a graph using pydot and such. Can anyone help me with this part? Thanks!

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>