Introducing here because tweepy that was used until this does not support api1.1 https://bitbucket.org/sakito/tweepy Probably as of February 12, 2013, it will be done manually instead of easy_install or pip. .. .. It worked just by copying tweepy2, which is created by unzipping the latest version in Downloads, to the same level as tweepy with cp -R.
hoge.py
#!/usr/bin/env python
# -*- coding:UTF-8 -*-
from oauth2 import Client, Consumer, Token
import tweepy2
consumer_key = ""
consumer_secret = ""
user_key = "-"
user_secret = ""
auth = tweepy2.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(user_key, user_secret)
client = Client(Consumer(consumer_key, consumer_secret),
Token(user_key, user_secret))
api = tweepy2.API(auth)
It seems that there is no problem with the OAuth token just by changing the part that was written as tweepy to tweepy2.
tweet.py
#!/usr/bin/env python
# -*- coding:UTF-8 -*-
import pywapi
from urllib import urlencode
import datetime
import hoge
result = pywapi.get_weather_from_yahoo('JAXX0043', 'metric')
time = datetime.datetime.now()
ms = time.microsecond
twit = u"@hoge The weather in Kumamoto from now to tonight" + result['forecasts'][0]['text'] + u"The temperature is the highest" \
+ result['forecasts'][0]['high'] \
+ u"The lowest is" + result['forecasts'][0]['low'] + u"About." + " #fkdr " + str(ms)
weth = twit.encode("utf-8")
hoge.client.request('https://api.twitter.com/1.1/statuses/update.json', 'POST', urlencode({'status': weth}))
This changed only by changing the url of the post part of the last line.
It seems that there is almost no problem with the introduction of tweepy2 and the change of the url that throws posts. If you are a person who has acquired TL or followers and is doing various things, there may be some obstacles. .. .. ..