作者sing10407 (阿U)
看板Web_Design
標題[問題] 使用jsp來取得FB accessToken內容?
時間Wed Apr 24 14:14:44 2013
我現在想要做使用FB來登入我的網站,
並取得FB照面、姓名即可
使用JSP,使用server side來做access token
目前可以取得Permission和連到 access Token的網址
當我看到facebook的範例中,看到php 的 file_get_contents就不會用了
請問有人用jsp寫過嗎? 到這邊的話使用jsp要如何取得使用者資訊呢?
以下是官網的php範例
$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$_SESSION['access_token'] = $params['access_token'];
$graph_url = "
https://graph.facebook.com/me?access_token="
. $params['access_token'];
$user = json_decode(file_get_contents($graph_url));
echo("Hello " . $user->name);
麻煩大家了
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.168.248.90
→ Fantasywind:那個函式就是取得$token_url那個網頁的原始碼 04/24 18:41
→ eric541:基本上不需要用到什麼套件就可以搞定了~給你參考看看 06/06 14:54