Skip to content

Instantly share code, notes, and snippets.

@mehdimehdi
Created April 6, 2012 23:11
Show Gist options
  • Save mehdimehdi/2323854 to your computer and use it in GitHub Desktop.
Save mehdimehdi/2323854 to your computer and use it in GitHub Desktop.
import urllib
import urllib2
from tweepy import oauth
CONSUMER_KEY = '50B4YwaUeSQvyCaFeI3TRg'
CONSUMER_SECRET = 'XXXX'
RESOURCE_URL = 'https://punchtab.uservoice.com/api/v1/tickets.json'
# Setup 2 legged OAuth consumer based on our admin "credentials"
consumer = oauth.OAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET)
# Construct the request manually and sign it using HMAC-SHA1
# Note: The params dictionary needs to be passed in separately from the base URL
request = oauth.OAuthRequest.from_consumer_and_token(
consumer, http_method='GET', http_url=RESOURCE_URL, parameters={})
request.sign_request(oauth.OAuthSignatureMethod_HMAC_SHA1(), consumer, None)
headers = request.to_header()
req = urllib2.Request(RESOURCE_URL, {}, headers)
response = urllib2.urlopen(req)
print response.read()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment