是用php取得user的timeline資料
找了很多文章
比較靠杯的是找到一個以為可以用的文~~~~其實不能用XD
可能是後來fb的api改版吧.......maybe
總之我不能用
http://johndoesdesign.com/blog/2011/php/adding-a-facebook-news-status-feed-to-a-website/
後來就再找找找
才找到可用的solution
其實很簡單
就幾段而已XD
以下是步驟~~~
先下載SDK
https://github.com/facebook/facebook-php-sdk
下載下來解壓縮放在server
新增facebook app
管他叫啥都好.....這部分我是用手機驗證才讓我新增app = =
新增之後要新增permission
read_stream
可是詭異的是我新增這個extended permission......
卻一直沒跑出來....詭異XD
好像是要等吧=_ =
因為Save Changes之後他說
Changes saved. Note that your changes may take several minutes to propagate to all servers.
看樣子應該不只是數分鐘XD
總之在user認可使用這app應該要有這東西
好了之後複製App ID, App Secret
貼到example/example.php裡面這段
$facebook = new Facebook( array('appId' => 'APP ID', 'secret' => 'App Secret', ));
然後開啟網頁
登入
確認使用此 app
在example目錄新增php檔案
檔案內容為
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New Web Project</title>
</head>
<body>
<pre>
<?php
require '../src/facebook.php';
$facebook = new Facebook( array('appId' => 'APP_ID', 'secret' => 'APP_SECRET', ));
$feed = $facebook -> api("/我是User的ID/feed", "GET", array('limit' => 100));
print_r($feed);
?>
</pre>
</body>
</html>
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New Web Project</title>
</head>
<body>
<pre>
<?php
require '../src/facebook.php';
$facebook = new Facebook( array('appId' => 'APP_ID', 'secret' => 'APP_SECRET', ));
$feed = $facebook -> api("/我是User的ID/feed", "GET", array('limit' => 100));
print_r($feed);
?>
</pre>
</body>
</html>
開啟這網頁就會顯示出這位user的news feed
大概長這樣
Array
(
[data] => Array
(
[0] => Array
(
[id] => 1111111111111111111111_2222222222222222222
[from] => Array
(
[name] => Bitty Ferrari
[id] => 11111111111111111111
)
[message] => [下午 12:27:08] Bitty: ..
[下午 01:23:06] Bitty: .....
[下午 01:23:10] Bitty: 這啥小情況
[下午 01:23:18] Bitty: 取 fb的feed
[下午 01:23:22] Bitty: 竟然不是最新的
[下午 01:23:25] Bitty: 是lagㄇ = =
[下午 01:41:16] Vince Chang: 錯
[下午 01:41:18] Vince Chang: 不是lag
[下午 01:41:35] Vince Chang: 是EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
[下午 01:42:03] Vince Chang: electric shock
[下午 01:47:35] Bitty: ......
[下午 01:47:37] Bitty: xdxdxdxxdxd
[picture] => https://fbexternal-a.akamaihd.net/safe_image.php?d=AQD0TMa_VCqMJnbw&w=130&h=130&url=http%3A%2F%2Fi3.ytimg.com%2Fvi%2Fn8I8QGFA1oM%2Fmqdefault.jpg
[link] => http://www.youtube.com/watch?v=n8I8QGFA1oM
[source] => http://www.youtube.com/v/n8I8QGFA1oM?version=3&autohide=1&autoplay=1
[name] => 에프엑스_Electric Shock_Music Video
[description] => ♬ Download on iTunes : http://itunes.apple.com/us/album/electric-shock-ep/id534866933 ☞ For more Information : http://www.smtown.com/ ☞ Facebook SMTOWN : htt...
[icon] => https://s-static.ak.facebook.com/rsrc.php/v2/yj/r/v2OnaTyTQZE.gif
[type] => video
[created_time] => 2012-08-09T05:51:32+0000
[updated_time] => 2012-08-09T05:51:32+0000
[likes] => Array
(
[data] => Array
(
[0] => Array
(
[name] => XXXX
[id] => 11111111111
)
)
[count] => 1
)
[comments] => Array
(
[count] => 0
)
)
reference
http://stackoverflow.com/questions/7319599/limit-since-and-until-parameters-in-page-feed
沒有留言:
發佈留言