facebook apps | oauth接続してみる 1
http://developers.facebook.com/docs/authentication/
http://www.facebook.com/developers
appを登録して sample codeをクリックすると以下のように。
Follow the simple steps below to create a working skeleton for your Application. Step 1: Download Facebook's PHP Library Extract this archive into a directory on your hosting server where you can host and run PHP code: $ curl -L http://github.com/facebook/php-sdk/tarball/master | tar xvz $ mv facebook-php-sdk-* facebook-php-sdk $ cp facebook-php-sdk/examples/example.php index.php Step 2: Replace the IDs in index.php to have your own app information It should look like this when you're done: <?php // Awesome Facebook Application // // Name: aucru // require_once 'facebook-php-sdk/src/facebook.php'; // Create our Application instance. $facebook = new Facebook(array( 'appId' => '', 'secret' => '', 'cookie' => true, )); Step 3: Test Your Application You're almost done! We just need to know two more things. Edit settings for your application and enter: The Canvas Callback URL - where your app is hosted. The Canvas Page URL - the apps.facebook.com/yourapp URL for your application.
facebook-php-sdk/examples/example.php
を該当ドメインの下に fbtest.phpとして置きました。
require_once ‘facebook-php-sdk/src/facebook.php';
を置いてあるpathに変更。
アクセスすると
php-sdk Login using OAuth 2.0 handled by the PHP SDK: Login with Facebook PHP Session Array ( ) You are not Connected.
Login with Facebookのリンクをクリックしてログインすると
php-sdk Logout PHP Session Array ( [fb_999999999999999_code] => [fb_999999999999999_access_token] => [fb_999999999999999_user_id] => ) You Your User Object (/me) Array ( [id] => 999999999999999 [name] => [first_name] => [last_name] => [link] => [location] => Array ( [id] => [name] => Shinagawa-ku, Tokyo, Japan )
な感じでデータ取得できました。
- Prev mecab ユーザー辞書登録
- Next permission設定 | facebook api
- Prev Microsoft スティーブ・バルマー講演を聴いて
- Next 1日で作るアンドロイドアプリ | Android