python-oauth2
python-oauth2 copied to clipboard
How to POST a json-formatted request?
trafficstars
I'm trying to do a status update into twitter. But it responds with: {"errors":[{"code":170,"message":"Missing required parameter: status."}]}
import json
import oauth2
token = oauth2.Token(
key=access_token['oauth_token'],
secret=access_token['oauth_token_secret'])
client = oauth2.Client(consumer, token)
status = 'Some weird test message'
message = {"status": status}
resp, content = client.request('https://api.twitter.com/1.1/statuses/update.json', 'POST',
body = json.dumps(message),
headers = {'Content-Type': 'application/json'})
Here's my problems:
- It's not apparent how to check what is actually sent.
- This has not been documented properly anywhere.
We've moved documentation on how to do twitter calls into the Wiki. I'm not sure if @rickhanlonii has updated yet so I appologise if its out of date.