我有一個網站,我想實現Facebook登錄設施..我瀏覽了Facebook開發者頁面,但他們有點模糊,無法完全理解。Facebook登錄實施
我的網站是一個php-mysql應用程序,我已經爲我的網站中的新用戶註冊了一個程序,但我希望用戶有一個用他們的facebook ID登錄的選項,並且一旦他們登錄,我想要將他們的ID存儲在我的mysql數據庫中以便下次識別它們。
我在SO中經歷過類似的話題,但無法破解它。如果任何人都可以將我鏈接到一步一步的明確指南,以在我的網站上實施此操作。
我有一個網站,我想實現Facebook登錄設施..我瀏覽了Facebook開發者頁面,但他們有點模糊,無法完全理解。Facebook登錄實施
我的網站是一個php-mysql應用程序,我已經爲我的網站中的新用戶註冊了一個程序,但我希望用戶有一個用他們的facebook ID登錄的選項,並且一旦他們登錄,我想要將他們的ID存儲在我的mysql數據庫中以便下次識別它們。
我在SO中經歷過類似的話題,但無法破解它。如果任何人都可以將我鏈接到一步一步的明確指南,以在我的網站上實施此操作。
只是做了一個快速的谷歌搜索,並發現以下博客文章:link。似乎涵蓋在PHP中設置FB登錄。
的帖子裏說,當你調用$facebook->require_login();
它會提示用戶使用FB登錄,然後在成功登錄,在返回你的FB的ID,這樣你可以寫類似$fb_id = $facebook->require_login();
,然後存儲$fb_id
。
下面是完整的Hello World示例 - 最好通過博客文章更完整的文檔閱讀:
<?php
/* include the PHP Facebook Client Library to help
with the API calls and make life easy */
require_once('facebook/client/facebook.php');
/* initialize the facebook API with your application API Key
and Secret */
$facebook = new Facebook(YOUR_API_KEY,YOUR_SECRET_CODE);
/* require the user to be logged into Facebook before
using the application. If they are not logged in they
will first be directed to a Facebook login page and then
back to the application's page. require_login() returns
the user's unique ID which we will store in fb_user */
$fb_user = $facebook->require_login();
/* now we will say:
Hello USER_NAME! Welcome to my first application! */
?>
Hello <fb:name uid='<?php echo $fb_user; ?>' useyou='false' possessive='true' />! Welcome to my first application!
<?php
/* We'll also echo some information that will
help us see what's going on with the Facebook API: */
echo "<pre>Debug:" . print_r($facebook,true) . "</pre>";
?>
呃,這是非常,非常舊代碼(從2007年開始!)這裏使用的Auth機制和FBML標籤已被棄用,現在都不能使用--OP會更好從https://developers.facebook.com開始。我認爲 – Igy