Rails3, Ruby on Rails, 技術, omniauth omniauthとは、マルチプロバイダ外部認証のためのRackベースシステムです。要はアプリケーションのログイン機能で、twitterやfacebookアカウント認証でのログインができるようになります。今回は既存のアプリケーションのログイン認証をtwitterとfacebook、mixiアカウントでの認証に変更したいと思います。基本的な流れを記述しましたが、メソッドのコードは自分のアプリケーションに合ったものに書き換えて下さい。この記事の内容は下記の内容に沿ったものです。https://github.com/railsapps/rails3-mongoid-omniauth/wiki/Tutorial omniauth gemのインストール# gemコマンドでインストールする場合 $ gem install omnia
ツイッターのオンライン・クライアントを自作するにあたって、まずはOAuth認証にトライ。 基本となる「ゼロから学ぶOAuth」を読もうと思ったのだが途中で飽きてしまったためあとで読むことにした。手っ取り早く「つながった感」を得られるサンプルコードを探す。下記の3つのサイトが大変役に立った。 PHP+OAuthでTwitter - SDN Project PHP+OAuth でTwitter連携アプリを作る!(Botも作れるよ!)[準備編] PHPでOAuthを使ったサンプルコード これらのサイトは共通して、Abraham Williams氏によるPHPライブラリ"twitteroauth"を使っている。面倒なことはライブラリがやってくれるし、逆に言えば何が行われているかよくわからなくてもOAuth認証ができてしまう。 一応サンプルコードをダウンロードして動かしてみたら……動いたよーん。 →
方法も何も、これさえできていれば PHPでTwitter APIのOAuthを使う方法まとめ – 頭ん中 一カ所書き換えるだけ。 事前の準備 アプリケーションを Sign in with Twitter に対応させときましょう。 https://twitter.com/apps に行く。 対象となるアプリケーションを選ぶ。(アプリケーション未登録の場合は上掲の記事に登録方法を書いているのでまずはそちらへ。) “Edit Application Settings” のボタンを押す。 一番下のあたりにある “Use Twitter for login” のところにチェックを入れて “Save” のボタンを押す。 はい完了。 Sign in with Twitter のやり方 OAuth でユーザーに承認してもらうとき、通常なら http://twitter.com/oauth/authoriz
ツイート前回の さくらVPSを借りてから参考にしたサイト でもお伝えしたとおり、今回はPHP + OAuth + twitter でログインするシステムを作るまでの道のりを、参考にしたサイトやコードを織り交ぜながら書いていこうと思います。 結果を先に書きますが、結局は非常に簡単で、シンプルな方法で実装できました。 最初にOAuthの基礎から。 ゼロから学ぶOAuth -gihyo.jp APIアクセス権を委譲するプロトコル、OAuthを知る – @IT まずは、ここを読んで実践してみました。 PHPでTwitter APIのOAuthを使う方法まとめ – 頭ん中 PHPで「Sign in with Twitter」を実装する方法 – 頭ん中 ふむふむ。さくらのVPSの初期状態では pearコマンドが使えないのでインストールが必要と。 PEARインストール(さくらVPSサーバー) – CAL
前回、Twitter botを作るための基礎知識としてTwitter APIについて説明しました。今回は実際にプログラムを組んでみましょう。ここでは例としてPHPでの発言方法を紹介します。 Twitter botに発言させてみる まずはPHPの標準機能を使って発言をしてみます。Twitter用ライブラリを使った発言については後ほど解説します。 <?php // curlリソースの作成 $curl = curl_init(); // ユーザ名 $username = "(ユーザ名を設定)"; // パスワード $password = "(パスワードを設定)"; // 発言する文字列を設定する // プログラムの文字コードがUTF-8の場合はこのまま $status = "日本語のテスト"; // プログラムの文字コードがSJISの場合はUTF-8に変換 //$status = mb_conv
This webpage was generated by the domain owner using Sedo Domain Parking. Disclaimer: Sedo maintains no relationship with third party advertisers. Reference to any specific service or trade mark is not controlled by Sedo nor does it constitute or imply its association, endorsement or recommendation.
この記事以降 Twitter API の仕様が変わっており、このままでは正しく機能しない場合があると思います。近いうちに今のやり方を書くので、それまで参考程度にご覧ください。 Twitter API の OAuth でひととおりやってみた。 忘れないようにメモ。 大雑把な流れ Twitter にアプリケーションを登録する。 Consumer Key と Consumer secret を取得する。 リクエストトークンを取得する。 認証用 URL を取得する。 ユーザーから承認を受ける(bot の場合は自分でやる)。 アクセストークンを取得する。 API にアクセスする。 以下、やった作業の手順です。 事前準備 HTTP_OAuth を使えるようにする OAuth の通信部分そのものは PEAR の HTTP_OAuth を使うことにしたので これをインストールする。 一番めんどくさい部分を
PHPで作ったゲームサイトでOAuthを利用したので、使い方やサンプルをメモしておきます。 このページ(SDN Project)を参考(というかそのまま)にしていますので、こちらも見てみてください。 OAuthも以前書いたOpenIDと同様に仕組みそのものは難しいのですが、サンプルを見ながら自分なりに変えていけば、それほど難しくなかったりします。 大まかな手順は、以下の通りです。 ①Twitterにアプリケーション登録をする ②OAuthのPHPをダウンロードする ③自分でPHPを書く ④サーバにアップ Twitterにアプリ登録 まず、Twitterに自分のアカウントでログインTwitterのOAuth申請のサイトから、自分のアプリケーション名やサイトのアドレスを登録します。 ・Application Nameは、自分のサービスの名前です。ユーザは認証する際にこのアプリケーション名を確認
Twitterが、「OAuth」仕様をサポートするインターフェースのベータをすべての開発者に向けて公開した。開発者はこれを利用して、サードパーティーのウェブサイトからTwitterのAPI経由でTwitterにアクセスできる。TwitterのAPIチームを率いるAlex Payne氏が米国時間3月16日、Twitterのつぶやきとして発表した。 OAuthは、オンライン認証のためのオープンな標準だ。OAuthを利用すると、特定のウェブサイトにパスワードなどの情報を保存しているユーザーは、他のウェブサイトでもそのデータを利用できる。しかも、自分のID情報を共有することはない。TwitterのOAuthに関するFAQによると、TwitterのOAuthサポートは数週間前、限定ベータとして一部の開発者に公開されていた。 OAuthの公式サイトでは、OAuthを「客の車の鍵を預かるボーイ」にたとえ
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く