http://offsidenow.phpapps.jp/archives/1664
・ Python2.7 ・ TwitterAPI1.1 ・ OAuth-Bibliothek (https://github.com/mikeknapp/AppEngine-OAuth-Library)
tweet.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from google.appengine.ext import webapp
#Geben Sie hier die zuvor erhaltenen Informationen an
TWITTER_CONSUMER_KEY = 'Verbraucherschlüssel'
TWITTER_CONSUMER_SECRET = 'Verbrauchergeheimnis'
TWITTER_ACCESS_TOKEN = 'Zugangstoken'
TWITTER_ACCESS_TOKEN_SECRET = 'Zugriffstoken geheim'
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"Guten Morgen"
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