Created
November 24, 2014 22:15
-
-
Save revox/bf98646ab12cee395051 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import twitter | |
import json | |
# == OAuth Authentication == | |
# The consumer keys can be found on your application's Details | |
# page located at https://dev.twitter.com/apps (under "OAuth settings") | |
consumer_key="" | |
consumer_secret="" | |
# After the step above, you will be redirected to your app's page. | |
# Create an access token under the the "Your access token" section | |
access_token="" | |
access_token_secret="" | |
auth = twitter.oauth.OAuth(access_token, access_token_secret,consumer_key, consumer_secret) | |
twitter_api = twitter.Twitter(auth=auth) | |
print twitter_api | |
# The Yahoo! Where On Earth ID for the entire world is 1. | |
# See https://dev.twitter.com/docs/api/1.1/get/trends/place and | |
# http://developer.yahoo.com/geo/geoplanet/ | |
WORLD_WOE_ID = 1 | |
US_WOE_ID = 23424977 | |
LONDON_WOE_ID = 44418 | |
# Prefix ID with the underscore for query string parameterization. | |
# Without the underscore, the twitter package appends the ID value | |
# to the URL itself as a special case keyword argument. | |
world_trends = twitter_api.trends.place(_id=WORLD_WOE_ID) | |
uk_trends = twitter_api.trends.place(_id=LONDON_WOE_ID) | |
# print in a readable format | |
print json.dumps(world_trends, indent=1) | |
print json.dumps(us_trends, indent=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment