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
        )

な感じでデータ取得できました。

This entry was posted on 水曜日, 5月 25th, 2011 at 3:13 AM and is filed under blog. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。