pythonでtwitterAPIを使用としたときのGAE上でのエラー
<class 'urllib2.HTTPError'>: HTTP Error 401: Unauthorized
GAE上にこの様なエラーが出てしまい。twitterbotに反映されません。
import urllib2は行っているのですが原因が分からず困っています。
よろしくお願いします
# -*- coding: utf-8 -*-
import twitter
import random
import os
# from tenki import information
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template
# twitter.Api.__init__ method for override.
def twitter_api_init_gae(self,
username=None,
password=None,
input_encoding=None,
request_headers=None):
import urllib2
from twitter import Api
self._cache = None
self._urllib = urllib2
self._cache_timeout = Api.DEFAULT_CACHE_TIMEOUT
self._InitializeRequestHeaders(request_headers)
self._InitializeUserAgent()
self._InitializeDefaultParameters()
self._input_encoding = input_encoding
self.SetCredentials(username, password)
# 天気用に追加
# from urllib2 import urlopen
# from xml.dom.minidom import parseString
# from xml.etree.ElementTree import *
# information = []
# io = urlopen("http://www.google.com/ig/api?weather=Tokyo")
# dom = ElementTree(file=io)
# cond = dom.find("//current_conditions")
# for name in ["condition","temp_c","humidity","wind_condition"]:
# information.append(cond.find(name).get("data"))
# overriding API __init__
twitter.Api.__init__ = twitter_api_init_gae
list = [
u"ante"
,u"Do my best"
,u"piyopiyopiyo"
,u"piyopiyo"
,u"ponyo"
,u"piyo"
,u"my name is anteroom"
# ,u"Today's weather is " + information[0]
# ,u"Today's weather is " + information[1]
# ,u"Today's weather is " + information[2]
# ,u"Today's weather is " + information[3]
]
post = random.choice(list)
api = twitter.Api("hoge","hoge")
api.PostUpdate(post)
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
似たような質問が見つかりました
- その他(プログラミング・Web制作) TwitterAPIを使用せずに自動ツイートする方法を知りたい。考え方としてはブラウザを擬似操作して 2 2023/02/02 17:16
- その他(プログラミング・Web制作) pythonのWebスクレイピングでfind_allだとurlがNoneに 4 2022/04/17 18:21
- その他(プログラミング・Web制作) pythonをjupiter notebookからmecabで頻出の高い単語の抽出について(Runt 1 2022/12/17 18:08
- その他(プログラミング・Web制作) このpythonコードの意味教えて下さい! 2 2022/08/26 00:52
- その他(プログラミング・Web制作) pythonのこのエラーがわかりません 3 2022/11/16 14:54
- その他(プログラミング・Web制作) Pythonで会員サイトの自動ログイン ID Nameがない 1 2022/12/16 02:09
- オープンソース Flaskでサーバー立ち上げに関して 1 2023/08/12 21:02
- その他(クラウドサービス・オンラインストレージ) Google ColabでGoogleドライブのサブフォルダにファイルを生成する方法 1 2022/10/31 17:37
- その他(プログラミング・Web制作) pythonのプログラムについての質問です。 1 2023/05/26 10:31
- その他(プログラミング・Web制作) Pythonのライブラリ、randomについて 3 2022/09/20 14:30
関連するカテゴリからQ&Aを探す
おすすめ情報
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
JavaScriptにて動的に配列を作...
-
javascriptの値をformのinput h...
-
Formの「action」属性を取得し...
-
時間の比較は可能でしょうか?
-
name属性とid属性の違い。DOMの...
-
imgタグ内 name とidの違い
-
テキストエリアをenterキーでフ...
-
JavascriptでのJSONデータの使い方
-
jQueryで属性連番処理を、複数...
-
正規表現で複数マッチ条件で悩...
-
ボタン2回押しを無効にしたい
-
<form action="#">の意味とは?
-
<td>の中のonClick="location" で
-
背景色を変えて未入力チェック...
-
【jsp/Java】チェックボックス...
-
javascriptで画像の移動
-
selectを変更不可にしたい
-
selectを使った計算
-
セレクトメニューで選択された...
-
テキストフィールドに入力した...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
【jQuery】input nameの文字列...
-
javascriptの値をformのinput h...
-
JavaScriptにて動的に配列を作...
-
新しくフォルダを作成したい
-
二つの入力欄に、同時に同じ文...
-
Javascriptでのbuttonのname属...
-
name属性のないformタグの、中...
-
テキストボックスの入力をリセット
-
出発駅A、到着駅Bを選択すると...
-
ASP.NETでNAME属性を固定にしたい
-
submitボタン押下時にPOSTされ...
-
ラジオボタンでクリックした値...
-
テキストボックスの値同士を比...
-
jqueryでtextareaのcols、rows...
-
入力フォームに半角スペース以...
-
cookie使用時にundefinedと表示...
-
ファイル選択ダイアログが表示...
-
テキストエリアをenterキーでフ...
-
hiddenを動的に作成したい
-
ボタンを押すとテキストボック...
おすすめ情報