もうだいぶ前の話しになるけど、なんとなくTwitterAPI+OAuthというのが触ってみたくて、こちらのブログを参考にプロトタイプを作りました。 参考にというか、ほぼコピペで。 検索とかポストとかは一通り問題なく行えたのですが、OAuthで認証後の自身のユーザー名の取得で躓きました。ad.lyとかやってるOAuthで認証後にユーザー名を表示してるやつ。 きっとトリッキーな事をしてると思いきやあっさり取れました。 躓いてたのはアクセストークンと同時に取れると思ったから。 もらったアクセストークンで、すぐにverify_credentialsというAPIを叩きユーザー名を含むユーザー情報を取得できます。 http://twitter.com/account/verify_credentials.xml これでOAuthを行ったユーザーの情報がとれます。
この記事以降 Twitter API の仕様が変わっており、このままでは正しく機能しない場合があると思います。近いうちに今のやり方を書くので、それまで参考程度にご覧ください。 Twitter API の OAuth でひととおりやってみた。 忘れないようにメモ。 大雑把な流れ Twitter にアプリケーションを登録する。 Consumer Key と Consumer secret を取得する。 リクエストトークンを取得する。 認証用 URL を取得する。 ユーザーから承認を受ける(bot の場合は自分でやる)。 アクセストークンを取得する。 API にアクセスする。 以下、やった作業の手順です。 事前準備 HTTP_OAuth を使えるようにする OAuth の通信部分そのものは PEAR の HTTP_OAuth を使うことにしたので これをインストールする。 一番めんどくさい部分を
準備 Twitter4J(TwitterAPIのJavaラッパ) twitter4jダウンロードサイトから最新安定ビルドtwitter4j-2.1.4-SNAPSHOT.zipをダウンロード eclipseでプロジェクトファイル直下にlibフォルダを作成し、ここに解凍したtwitter4jフォルダ内の twitter4j-core-2.1.4-SNAPSHOT.jarをコピーする。 [プロジェクト]→右クリック[プロパティ]→左メニュー[javaのビルドパス]→[jarの追加]→コピーしたjarファイル を選択しOK。 ソース説明 Twitterのユーザ名とパスワードを入力しボタンを押すと、xAuth認証を実行し、自動で定型文を投稿する。 twittertest.java(メインアクティビティ) main.xml(メインのレイアウト) twittertest.java public cla
カテゴリー ActionScript (24) Adobe Flash Collaboration Service (1) AIR (31) Amazon EC2 (9) Amazon S3 (3) Android (19) Apache (5) Archiver (1) bind (2) Block Breaker (9) Blogger (5) BootCamp (2) CentOS (26) chkrootkit (1) ClamAV (2) Cloud Computing (2) Cocomo (3) cs3 (7) cs4 (2) CSS (2) cybozu2ical (1) dovecot (5) Event report (4) Exec-Shield (1) FeliCa (2) Firefox (5) flash (5) flashcast (10) Flex (17)
Twitter のDevelopから 「もうちょい詳しい説明をくれ」 とのことだったので、 「 アプリ 開発 に使いたいから、許可してくれ」 的なことを再度送りました。 Hi Taro, Thank you for your interest in xAuth. Unfortunately, we are not granting xAuth for initial development purposes. Instead, I recommend that you set up a one-time OAuth workflow to obtain the access token for a single account, and then use that token going forward to authorize your API calls. We provide a t
androidアプリを暇つぶしで作っておりまして、その記録です。 最近、iOSアプリとかIoTとかにも手を広げ始めたので、ブログタイトルに「とか」を入れました。 「やりたいことを我慢しなくてよい世の中にしたい」という思いで仕事に取り組んでいます。 【セルフPR】 ・ねこぱβ(http://cat.picparks.com) ・いぬぱβ(http://dog.picparks.com) も見てくれると嬉しいです。 --- Twitterクライアントを作るに当たって必要な認証方法として、 前のエントリで書いたように、Twitterサポートとのやり取りや、 セキュリティ面からオススメしない認証方法であるxAuth。 とは言え、ある程度の需要もあると思われるので、 Twitter4jを使った場合のコーディング例を、一応紹介。 ■開発環境 ・JDK 6 ・Android SDK Tools, Rev
androidアプリを暇つぶしで作っておりまして、その記録です。 最近、iOSアプリとかIoTとかにも手を広げ始めたので、ブログタイトルに「とか」を入れました。 「やりたいことを我慢しなくてよい世の中にしたい」という思いで仕事に取り組んでいます。 【セルフPR】 ・ねこぱβ(http://cat.picparks.com) ・いぬぱβ(http://dog.picparks.com) も見てくれると嬉しいです。 --- Twitter4jは2.1系から2.2系で使い方が変わったので、2.2系をお使いになる場合は、こちらの記事をご覧ください。 Twitterクライアントを作るに当たって必要な認証方法として、 前のエントリで書いたように、よりセキュアな認証方法であるOAuth。 Twitter4jとSignpostの併用とか訳の分からないコーディングや、 返ってきたaccess_tokenをユ
OAuthによるTwitter通信を行うプログラムを作成する。 アプリの登録 Twitterの連携アプリの登録ページでアプリの登録を行う。 アプリケーションの種類は「ブラウザアプリ」、コールバックURLには適当なURLを記述。 インテントでWebブラウザを開いて認証を行い、証明書となるトークンを元のアクティビティに戻してもらうため。 consumerKeyとconsumerSecretを取得し、ソースコードに記述。 ライブラリの追加 オープンソースライブラリ「oauth-signpost」を使用する。 「signpost-core-1.2.1.1.jar」と「signpost-commonshttp4-1.2.1.1.jar」をダウンロードしてパスを通す。ライブラリの追加方法は「Package Explorerのプロジェクト名を右クリック→Properties→Java Bu
はじめに どうもKRAYの芳賀です。 今日はツイッターサービスをスピーディーかつ無料で作るお話です。 僕は日頃趣味でツイッターサービスを作っているのですが、アイデアを着想したその日のうちにプロトタイプを作って動かすことができるくらいにノウハウが溜まってきました。 仕事が終わってからのプライベートな時間だけでも、1週間から1か月もあれば1つサービスがリリースできる感覚がつかめたので、必要最低限の機能を備えたサービスを短時間で作れないだろうか?と時間を計測しつつ実践してみたところ、なんと1時間で完成できたので、その手順を紹介します。 開発の流れ まずは開発の流れを説明します。 ツイッターアカウントの用意 まずツイッターのアカウントが必要になるので、まだ持っていなければ取得しましょう。サービス用に改めて取得してもいいですね。 サーバの用意 作成したウェブアプリを設置するサーバを準備します。PHP
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く