http://offsidenow.phpapps.jp/archives/1664
・ Python2.7 ・ TwitterAPI1.1 ・ Bibliothèque OAuth (https://github.com/mikeknapp/AppEngine-OAuth-Library)
tweet.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from google.appengine.ext import webapp
#Précisez chaque information obtenue précédemment ici
TWITTER_CONSUMER_KEY = 'La clé du consommateur'
TWITTER_CONSUMER_SECRET = 'Secret du consommateur'
TWITTER_ACCESS_TOKEN = 'Jeton d'accès'
TWITTER_ACCESS_TOKEN_SECRET = 'Secret du jeton d'accès'
class TweetHandler(webapp.RequestHandler):
def get(self):
from extends.GAE_Oauth import oauth
client = oauth.TwitterClient(TWITTER_CONSUMER_KEY,
TWITTER_CONSUMER_SECRET, None)
tweet = u"Bonjour"
param = {'status': tweet}
client.make_request('https://api.twitter.com/1.1/statuses/update.json',
token=TWITTER_ACCESS_TOKEN,
secret=TWITTER_ACCESS_TOKEN_SECRET,
additional_params=param,
protected=True,
method='POST')
self.response.out.write(tweet)
Recommended Posts