Skip to content

Instantly share code, notes, and snippets.

@revox
Created November 24, 2014 22:15
Show Gist options
  • Save revox/bf98646ab12cee395051 to your computer and use it in GitHub Desktop.
Save revox/bf98646ab12cee395051 to your computer and use it in GitHub Desktop.
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
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