Skip to content

Instantly share code, notes, and snippets.

@m0n5t3r
Created June 20, 2013 20:08
Show Gist options
  • Save m0n5t3r/5826163 to your computer and use it in GitHub Desktop.
Save m0n5t3r/5826163 to your computer and use it in GitHub Desktop.
bti replacement, because Twittre decided to shut down API version 1.0 and break clients...
#!/usr/bin/env python
import sys
import requests
from requests_oauthlib import OAuth1
if __name__ == '__main__':
consumer_key = '...'
consumer_secret = '...'
access_token_key = '...'
access_token_secret = '...'
api_url = 'https://api.twitter.com/1.1/statuses/update.json'
auth = OAuth1(consumer_key, consumer_secret, access_token_key, access_token_secret, signature_type='auth_header')
message = {
'status': len(sys.argv) > 1 and ' '.join(sys.argv[1:]) or sys.stdin.read(),
}
if not message['status']:
print 'No input data, bailing out!'
exit(1)
requests.post(api_url, message, auth=auth)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment