SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Google App Engine で Twitter アプリを作ろう 2010 年 8 月 S-cubism 技術勉強会 細田謙二
Twitter について
Google App Engine について
Google App Engine で できること なんといってもタダ! ウェブサービスだけではない URL フェッチやクーロンタスク も可能
こんなことが可能 ダウンロード 個人レベルでの データ集約&解析
本日のレシピ Google App Engine で Tweet Aggregator を作る Web2py OAuth Twitter API Google App Engine
tweepy ライブラリを利用する ,[object Object],[object Object],ん。。 OAuth って?
Twitter の利用制限 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
OAuth の設定1 ,[object Object],[object Object],[object Object],Twitter  にてアプリケーション登録
OAuth の設定2 import tweepy auth = tweepy.OAuthHandler( consumer_key ,  consumer_secret ) (以降  tweepy  を利用) 取得した " consumer token " から auth オブジェクトを作成
OAuth の設定3 redirect_url  = auth.get_authorization_url() request_key  = auth.request_token.key request_secret  = auth.request_token.secret これらの出力をメモ " redirect url "  と " request token " を取得
OAuth の設定4 1234567 7 桁の数字が表示されるので、 これもメモ 取得した " redirect url " を ( twitter にログインした状態で)開く
OAuth の設定5 auth.set_request_token( request_key ,  request_secret ) auth.get_access_token( verifier_digits ) access_key  = auth.access_token.key  access_secret  = auth.access_token.secret 取得した 7 桁の数字 これらの出力をメモ " access token " の取得
OAuth の設定6 auth.set_access_token( access_key ,  access_secret ) #  これで API が利用可能に! api  = tweepy.API(auth) api オブジェクトの作成
こんな感じでツイートを収集 # since_id 以降のツイートを最大 200 件取得 tweets =  api .home_timeline( since_id,  count=200) for tweet in tweets: tweet.id tweet.text ...
Aggregator を作る ,[object Object],[object Object],[object Object],[object Object],[object Object]
Web2py を利用する ,[object Object],[object Object],[object Object],[object Object]
ツイートモデルを定義 db.define_table('tweet', Field('uuid', 'integer'), Field('tweeted_at', 'datetime'), Field('content', 'string'), Field('user_name', 'string'), Field('user_image', 'string'), Field('read_flg', 'boolean', default=False), )) Web2py の db オブジェクト Web2py の model 内で定義 未読 / 既読の設定
未読のみ表示してみる #  未読ツイートの取得 tweets = db( db.tweet.read_flg==False   ).select( limitby=(start, end), orderby=~db.tweet.tweeted_at) #  既読に設定 for tweet in tweets:  tweet.update_record( read_flg=True )  # ビューで表示 return dict(tweets=tweets) Web2py の controller 内の関数
Google App Engine にデプロイ ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
デモ
こんなことができる(かも) ,[object Object],[object Object],[object Object],[object Object]

Weitere ähnliche Inhalte

Andere mochten auch

Pythonおじさんのweb2py挑戦記
Pythonおじさんのweb2py挑戦記Pythonおじさんのweb2py挑戦記
Pythonおじさんのweb2py挑戦記Yoshiyuki Nakamura
 
Getting started with ES6 : Future of javascript
Getting started with ES6 : Future of javascriptGetting started with ES6 : Future of javascript
Getting started with ES6 : Future of javascriptMohd Saeed
 
JavaScript.Next Returns
JavaScript.Next ReturnsJavaScript.Next Returns
JavaScript.Next Returnsdynamis
 
ES6 はじめました
ES6 はじめましたES6 はじめました
ES6 はじめましたNet Kanayan
 
Prototypeベース in JavaScript
Prototypeベース in JavaScriptPrototypeベース in JavaScript
Prototypeベース in JavaScriptRyo Maruyama
 
JavaScript : What is it really? AND Some new features in ES6
JavaScript : What is it really? AND Some new features in ES6JavaScript : What is it really? AND Some new features in ES6
JavaScript : What is it really? AND Some new features in ES6Aayush Shrestha
 
FileReader and canvas and server silde
FileReader and canvas and server sildeFileReader and canvas and server silde
FileReader and canvas and server sildeNet Kanayan
 
はじめてのWallaby.js
はじめてのWallaby.jsはじめてのWallaby.js
はじめてのWallaby.jsShunta Saito
 
ECMAScript 6 Features(PDF 版)
ECMAScript 6 Features(PDF 版)ECMAScript 6 Features(PDF 版)
ECMAScript 6 Features(PDF 版)taskie
 
Nds meetup8 lt
Nds meetup8 ltNds meetup8 lt
Nds meetup8 ltushiboy
 
断言して間違えると信頼度が低下するというベイズの話
断言して間違えると信頼度が低下するというベイズの話断言して間違えると信頼度が低下するというベイズの話
断言して間違えると信頼度が低下するというベイズの話Junya Hayashi
 
アニメーションの実装つらい話
アニメーションの実装つらい話アニメーションの実装つらい話
アニメーションの実装つらい話kata shin
 

Andere mochten auch (20)

Pythonおじさんのweb2py挑戦記
Pythonおじさんのweb2py挑戦記Pythonおじさんのweb2py挑戦記
Pythonおじさんのweb2py挑戦記
 
jQuery勉強会#4
jQuery勉強会#4jQuery勉強会#4
jQuery勉強会#4
 
Getting started with ES6 : Future of javascript
Getting started with ES6 : Future of javascriptGetting started with ES6 : Future of javascript
Getting started with ES6 : Future of javascript
 
kontainer-js
kontainer-jskontainer-js
kontainer-js
 
JavaScript.Next Returns
JavaScript.Next ReturnsJavaScript.Next Returns
JavaScript.Next Returns
 
ES6 はじめました
ES6 はじめましたES6 はじめました
ES6 はじめました
 
JavaScript 実践講座 Framework, Tool, Performance
JavaScript 実践講座 Framework, Tool, PerformanceJavaScript 実践講座 Framework, Tool, Performance
JavaScript 実践講座 Framework, Tool, Performance
 
Prototypeベース in JavaScript
Prototypeベース in JavaScriptPrototypeベース in JavaScript
Prototypeベース in JavaScript
 
JavaScript : What is it really? AND Some new features in ES6
JavaScript : What is it really? AND Some new features in ES6JavaScript : What is it really? AND Some new features in ES6
JavaScript : What is it really? AND Some new features in ES6
 
150421 es6とかな話
150421 es6とかな話150421 es6とかな話
150421 es6とかな話
 
ES6 - JavaCro 2016
ES6 - JavaCro 2016ES6 - JavaCro 2016
ES6 - JavaCro 2016
 
FileReader and canvas and server silde
FileReader and canvas and server sildeFileReader and canvas and server silde
FileReader and canvas and server silde
 
はじめてのWallaby.js
はじめてのWallaby.jsはじめてのWallaby.js
はじめてのWallaby.js
 
Startup JavaScript
Startup JavaScriptStartup JavaScript
Startup JavaScript
 
ECMAScript 6 Features(PDF 版)
ECMAScript 6 Features(PDF 版)ECMAScript 6 Features(PDF 版)
ECMAScript 6 Features(PDF 版)
 
Hello npm
Hello npmHello npm
Hello npm
 
Nds meetup8 lt
Nds meetup8 ltNds meetup8 lt
Nds meetup8 lt
 
断言して間違えると信頼度が低下するというベイズの話
断言して間違えると信頼度が低下するというベイズの話断言して間違えると信頼度が低下するというベイズの話
断言して間違えると信頼度が低下するというベイズの話
 
アニメーションの実装つらい話
アニメーションの実装つらい話アニメーションの実装つらい話
アニメーションの実装つらい話
 
Learn ES2015
Learn ES2015Learn ES2015
Learn ES2015
 

Ähnlich wie Google App EngineでTwitterアプリを作ろう

第四回Web apiを使ってwebアプリケーションを作る勉強会テキスト2
第四回Web apiを使ってwebアプリケーションを作る勉強会テキスト2第四回Web apiを使ってwebアプリケーションを作る勉強会テキスト2
第四回Web apiを使ってwebアプリケーションを作る勉強会テキスト2脇村 隆
 
React(TypeScript) + Go + Auth0 で実現する管理画面
React(TypeScript) + Go + Auth0 で実現する管理画面React(TypeScript) + Go + Auth0 で実現する管理画面
React(TypeScript) + Go + Auth0 で実現する管理画面KentaEndoh
 
AWS Amplify - Auth/API Category & Vue 構築ハンズオン
AWS Amplify - Auth/API Category & Vue 構築ハンズオンAWS Amplify - Auth/API Category & Vue 構築ハンズオン
AWS Amplify - Auth/API Category & Vue 構築ハンズオンEiji KOMINAMI
 
Tokyo Jazug Night 2020-01 Azure Monitor を使った運用監視コトハジメ
Tokyo Jazug Night 2020-01 Azure Monitor を使った運用監視コトハジメTokyo Jazug Night 2020-01 Azure Monitor を使った運用監視コトハジメ
Tokyo Jazug Night 2020-01 Azure Monitor を使った運用監視コトハジメTsubasa Yoshino
 
python-twitterを用いたTwitterデータ収集
python-twitterを用いたTwitterデータ収集python-twitterを用いたTwitterデータ収集
python-twitterを用いたTwitterデータ収集Hikaru Takemura
 
あなたの安心を高速に守る Container-based CI
あなたの安心を高速に守る Container-based CIあなたの安心を高速に守る Container-based CI
あなたの安心を高速に守る Container-based CIWataru MIYAGUNI
 
Opauthライブラリによるtwitter,facebook認証について
Opauthライブラリによるtwitter,facebook認証についてOpauthライブラリによるtwitter,facebook認証について
Opauthライブラリによるtwitter,facebook認証について松本 雄貴
 
plusbenlly meetiup how-to-use
plusbenlly meetiup how-to-useplusbenlly meetiup how-to-use
plusbenlly meetiup how-to-useKohji Fujishima
 
Oisix勉強会 google analiticsapiを使用したサイト開発例
Oisix勉強会 google analiticsapiを使用したサイト開発例Oisix勉強会 google analiticsapiを使用したサイト開発例
Oisix勉強会 google analiticsapiを使用したサイト開発例oistudy
 
[使い倒し]GitHubのIssueとTFS/VSOのWorkItem連動に挑む(2015/08/26)
[使い倒し]GitHubのIssueとTFS/VSOのWorkItem連動に挑む(2015/08/26)[使い倒し]GitHubのIssueとTFS/VSOのWorkItem連動に挑む(2015/08/26)
[使い倒し]GitHubのIssueとTFS/VSOのWorkItem連動に挑む(2015/08/26)Masanori Ishigami
 
Google+APIをさわってみる。
Google+APIをさわってみる。Google+APIをさわってみる。
Google+APIをさわってみる。Hiroyuki Nozaki
 
Dropbox APIなどを使って制作を効率化しよう@関西オープンフォーラム
Dropbox APIなどを使って制作を効率化しよう@関西オープンフォーラムDropbox APIなどを使って制作を効率化しよう@関西オープンフォーラム
Dropbox APIなどを使って制作を効率化しよう@関西オープンフォーラムMasayuki Abe
 
Google+ API の紹介 - Google Social Developers 2011 Winter
Google+ API の紹介 - Google Social Developers 2011 WinterGoogle+ API の紹介 - Google Social Developers 2011 Winter
Google+ API の紹介 - Google Social Developers 2011 WinterNobuhiro Nakajima
 
Azure Serverless or Power Platform 〜 あなたならどっち?! - Azure Serverless 編
Azure Serverless or Power Platform 〜 あなたならどっち?! - Azure Serverless 編Azure Serverless or Power Platform 〜 あなたならどっち?! - Azure Serverless 編
Azure Serverless or Power Platform 〜 あなたならどっち?! - Azure Serverless 編Kazumi IWANAGA
 
OAuth2.0によるWeb APIの保護
OAuth2.0によるWeb APIの保護OAuth2.0によるWeb APIの保護
OAuth2.0によるWeb APIの保護Naohiro Fujie
 
イマドキ!ユースケース別に見るAWS IoT への接続パターン
イマドキ!ユースケース別に見るAWS IoT への接続パターンイマドキ!ユースケース別に見るAWS IoT への接続パターン
イマドキ!ユースケース別に見るAWS IoT への接続パターンseiichi arai
 
Programming AWS with Python
Programming AWS with Python  Programming AWS with Python
Programming AWS with Python Yasuhiro Matsuo
 
BPStudy #40 - Google Appengine 1.4.0
BPStudy #40 - Google Appengine 1.4.0BPStudy #40 - Google Appengine 1.4.0
BPStudy #40 - Google Appengine 1.4.0Ian Lewis
 
第一回Rest勉強会 ワークショップ
第一回Rest勉強会 ワークショップ第一回Rest勉強会 ワークショップ
第一回Rest勉強会 ワークショップksimoji
 

Ähnlich wie Google App EngineでTwitterアプリを作ろう (20)

第四回Web apiを使ってwebアプリケーションを作る勉強会テキスト2
第四回Web apiを使ってwebアプリケーションを作る勉強会テキスト2第四回Web apiを使ってwebアプリケーションを作る勉強会テキスト2
第四回Web apiを使ってwebアプリケーションを作る勉強会テキスト2
 
React(TypeScript) + Go + Auth0 で実現する管理画面
React(TypeScript) + Go + Auth0 で実現する管理画面React(TypeScript) + Go + Auth0 で実現する管理画面
React(TypeScript) + Go + Auth0 で実現する管理画面
 
AWS Amplify - Auth/API Category & Vue 構築ハンズオン
AWS Amplify - Auth/API Category & Vue 構築ハンズオンAWS Amplify - Auth/API Category & Vue 構築ハンズオン
AWS Amplify - Auth/API Category & Vue 構築ハンズオン
 
Tokyo Jazug Night 2020-01 Azure Monitor を使った運用監視コトハジメ
Tokyo Jazug Night 2020-01 Azure Monitor を使った運用監視コトハジメTokyo Jazug Night 2020-01 Azure Monitor を使った運用監視コトハジメ
Tokyo Jazug Night 2020-01 Azure Monitor を使った運用監視コトハジメ
 
python-twitterを用いたTwitterデータ収集
python-twitterを用いたTwitterデータ収集python-twitterを用いたTwitterデータ収集
python-twitterを用いたTwitterデータ収集
 
あなたの安心を高速に守る Container-based CI
あなたの安心を高速に守る Container-based CIあなたの安心を高速に守る Container-based CI
あなたの安心を高速に守る Container-based CI
 
Opauthライブラリによるtwitter,facebook認証について
Opauthライブラリによるtwitter,facebook認証についてOpauthライブラリによるtwitter,facebook認証について
Opauthライブラリによるtwitter,facebook認証について
 
plusbenlly meetiup how-to-use
plusbenlly meetiup how-to-useplusbenlly meetiup how-to-use
plusbenlly meetiup how-to-use
 
Oisix勉強会 google analiticsapiを使用したサイト開発例
Oisix勉強会 google analiticsapiを使用したサイト開発例Oisix勉強会 google analiticsapiを使用したサイト開発例
Oisix勉強会 google analiticsapiを使用したサイト開発例
 
[使い倒し]GitHubのIssueとTFS/VSOのWorkItem連動に挑む(2015/08/26)
[使い倒し]GitHubのIssueとTFS/VSOのWorkItem連動に挑む(2015/08/26)[使い倒し]GitHubのIssueとTFS/VSOのWorkItem連動に挑む(2015/08/26)
[使い倒し]GitHubのIssueとTFS/VSOのWorkItem連動に挑む(2015/08/26)
 
Google+APIをさわってみる。
Google+APIをさわってみる。Google+APIをさわってみる。
Google+APIをさわってみる。
 
Dropbox APIなどを使って制作を効率化しよう@関西オープンフォーラム
Dropbox APIなどを使って制作を効率化しよう@関西オープンフォーラムDropbox APIなどを使って制作を効率化しよう@関西オープンフォーラム
Dropbox APIなどを使って制作を効率化しよう@関西オープンフォーラム
 
Google+ API の紹介 - Google Social Developers 2011 Winter
Google+ API の紹介 - Google Social Developers 2011 WinterGoogle+ API の紹介 - Google Social Developers 2011 Winter
Google+ API の紹介 - Google Social Developers 2011 Winter
 
Twitter API
Twitter APITwitter API
Twitter API
 
Azure Serverless or Power Platform 〜 あなたならどっち?! - Azure Serverless 編
Azure Serverless or Power Platform 〜 あなたならどっち?! - Azure Serverless 編Azure Serverless or Power Platform 〜 あなたならどっち?! - Azure Serverless 編
Azure Serverless or Power Platform 〜 あなたならどっち?! - Azure Serverless 編
 
OAuth2.0によるWeb APIの保護
OAuth2.0によるWeb APIの保護OAuth2.0によるWeb APIの保護
OAuth2.0によるWeb APIの保護
 
イマドキ!ユースケース別に見るAWS IoT への接続パターン
イマドキ!ユースケース別に見るAWS IoT への接続パターンイマドキ!ユースケース別に見るAWS IoT への接続パターン
イマドキ!ユースケース別に見るAWS IoT への接続パターン
 
Programming AWS with Python
Programming AWS with Python  Programming AWS with Python
Programming AWS with Python
 
BPStudy #40 - Google Appengine 1.4.0
BPStudy #40 - Google Appengine 1.4.0BPStudy #40 - Google Appengine 1.4.0
BPStudy #40 - Google Appengine 1.4.0
 
第一回Rest勉強会 ワークショップ
第一回Rest勉強会 ワークショップ第一回Rest勉強会 ワークショップ
第一回Rest勉強会 ワークショップ
 

Google App EngineでTwitterアプリを作ろう

  • 1. Google App Engine で Twitter アプリを作ろう 2010 年 8 月 S-cubism 技術勉強会 細田謙二
  • 3. Google App Engine について
  • 4. Google App Engine で できること なんといってもタダ! ウェブサービスだけではない URL フェッチやクーロンタスク も可能
  • 6. 本日のレシピ Google App Engine で Tweet Aggregator を作る Web2py OAuth Twitter API Google App Engine
  • 7.
  • 8.
  • 9.
  • 10. OAuth の設定2 import tweepy auth = tweepy.OAuthHandler( consumer_key , consumer_secret ) (以降 tweepy を利用) 取得した " consumer token " から auth オブジェクトを作成
  • 11. OAuth の設定3 redirect_url = auth.get_authorization_url() request_key = auth.request_token.key request_secret = auth.request_token.secret これらの出力をメモ " redirect url " と " request token " を取得
  • 12. OAuth の設定4 1234567 7 桁の数字が表示されるので、 これもメモ 取得した " redirect url " を ( twitter にログインした状態で)開く
  • 13. OAuth の設定5 auth.set_request_token( request_key , request_secret ) auth.get_access_token( verifier_digits ) access_key = auth.access_token.key access_secret = auth.access_token.secret 取得した 7 桁の数字 これらの出力をメモ " access token " の取得
  • 14. OAuth の設定6 auth.set_access_token( access_key , access_secret ) # これで API が利用可能に! api = tweepy.API(auth) api オブジェクトの作成
  • 15. こんな感じでツイートを収集 # since_id 以降のツイートを最大 200 件取得 tweets = api .home_timeline( since_id, count=200) for tweet in tweets: tweet.id tweet.text ...
  • 16.
  • 17.
  • 18. ツイートモデルを定義 db.define_table('tweet', Field('uuid', 'integer'), Field('tweeted_at', 'datetime'), Field('content', 'string'), Field('user_name', 'string'), Field('user_image', 'string'), Field('read_flg', 'boolean', default=False), )) Web2py の db オブジェクト Web2py の model 内で定義 未読 / 既読の設定
  • 19. 未読のみ表示してみる # 未読ツイートの取得 tweets = db( db.tweet.read_flg==False   ).select( limitby=(start, end), orderby=~db.tweet.tweeted_at) # 既読に設定 for tweet in tweets: tweet.update_record( read_flg=True ) # ビューで表示 return dict(tweets=tweets) Web2py の controller 内の関数
  • 20.
  • 22.