這是明郅資訊的粉絲專頁 - 明郅奇幻星球 ( https://www.facebook.com/mjapptech )
接下來要講解只要有臉書帳號就可以做的事情
--
進入 Facebook 圖形 API 測試工具 或 https://developers.facebook.com/tools/explorer/
後以臉書帳號登入
目前 Facebook 的 API 從 v2.2 ~ v2.8 ,每個版本都有差異,不過最大的差異是以 v2.3 為切割點,後面會講到,自己切換測試也可得知
--
v2.8/mjapptech
1 2 3 4 |
{ "name": "明郅奇幻星球-Mj", "id": "1508002559485075" } |
所以換成這樣也可以取得相同結果
v2.8/1508002559485075
1 2 3 4 |
{ "name": "明郅奇幻星球-Mj", "id": "1508002559485075" } |
--
取得粉絲團文章
v2.8/mjapptech?fields=feed
1 2 |
: : |
太多了就不貼了,順便講限制筆數
v2.8/1508002559485075?fields=feed.limit(3)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
{ "feed": { "data": [ { "message": "從1948年到2034年的85年間, 地球與月球最接近的一次「超級滿月」 今晚將登場,錯過今天,就要再等18年。 ➡️今晚7時23分為最大!!!! ➡️小星球就搞威 (Line貼圖,現正熱賣中) http://goo.gl/8syLHg #超級月亮 #滿月 #賞月 #歲月不等人 #再等十八年皺紋都不知道多了幾百條", "story": "明郅奇幻星球-Mj feeling relaxed.", "created_time": "2016-11-14T08:49:26+0000", "id": "1508002559485075_1821201524831842" }, { "story": "Phenix Fu shared a post to 明郅奇幻星球-Mj's Timeline.", "created_time": "2016-11-12T09:44:40+0000", "id": "1508002559485075_10154166582497879" }, { "message": "【加碼】分享數如達100人,加碼再抽5本!你分享了沒?! 明郅小星球與馨琳揚聯名發行的2017年小桌曆上市囉! 我們將在粉絲團抽獎贈送10本。 參加方法:即日起只要對本篇文章、和對我們的 明郅奇幻星球-Mj 粉絲團按讚,並分享本篇文章! 我們會在12/25號前抽出幸運的小粉絲們,贈送超級實用的星座小桌曆喔!超級可愛的內容,大家把握機會別錯過了! #2017桌曆 #明郅小星球", "story": "明郅奇幻星球-Mj added 2 new photos.", "created_time": "2016-11-12T09:42:15+0000", "id": "1508002559485075_1820251104926884" } ], "paging": { "previous": "https://graph.facebook.com/v2.8/1508002559485075/feed?limit=3&since=1479113366&access_token=EAACEdEose0cBAPSILwOwZCMdPJZCRSoSYQg3z58zIaq86xUhVg6DeOwGVGNiDzxykh1W6sfaX4BDwg9Q2EuANZCvrpSyZAlY0jpwzLLAWtFqCXet4kBrWca2uo4LLMOw6ZCZCvHlc4o70r3MgyRTwpq8ZCiZAhWILLposhIQQIWLygZDZD&__paging_token=enc_AdAKqYWJkBbTGjOYlhKpoCnop1ZCnTTxLZBKCZAPCamDgAjZB63NEHFSO3DSUNsyPgNljTayipfgQKkZBhhE2PKP6uIAMXFuwZAxOlM3okgYfPjk4z2AZDZD&__previous=1", "next": "https://graph.facebook.com/v2.8/1508002559485075/feed?limit=3&access_token=EAACEdEose0cBAPSILwOwZCMdPJZCRSoSYQg3z58zIaq86xUhVg6DeOwGVGNiDzxykh1W6sfaX4BDwg9Q2EuANZCvrpSyZAlY0jpwzLLAWtFqCXet4kBrWca2uo4LLMOw6ZCZCvHlc4o70r3MgyRTwpq8ZCiZAhWILLposhIQQIWLygZDZD&until=1478943735&__paging_token=enc_AdBSH4PsFUrS7Hq7ZB4XFqCtpC12OmXvooHL89yVFQcHI9ZBZCC8QABIeEVGJXbvNKrjrKRkUSRuvI2m4jNYEdOmUW5yZAAP4lxTayZCiFiZBvnSJ5mQZDZD" } }, "id": "1508002559485075" } |
--
Post 文查詢
將粉絲專業 id 加底線加 Post 文 id 即可取得完整的 post_id
例如這篇 https://www.facebook.com/mjapptech/posts/1820251104926884 ,從網址即可得知 Post 文 id 為 1820251104926884 ,粉絲團 id 為 1508002559485075
所以 post_id = 1508002559485075_1820251104926884
--
v2.8/1508002559485075_1820251104926884
1 2 3 4 5 6 7 8 9 10 11 |
{ "created_time": "2016-11-12T09:42:15+0000", "message": "【加碼】分享數如達100人,加碼再抽5本!你分享了沒?! 明郅小星球與馨琳揚聯名發行的2017年小桌曆上市囉! 我們將在粉絲團抽獎贈送10本。 參加方法:即日起只要對本篇文章、和對我們的 明郅奇幻星球-Mj 粉絲團按讚,並分享本篇文章! 我們會在12/25號前抽出幸運的小粉絲們,贈送超級實用的星座小桌曆喔!超級可愛的內容,大家把握機會別錯過了! #2017桌曆 #明郅小星球", "story": "明郅奇幻星球-Mj added 2 new photos.", "id": "1508002559485075_1820251104926884" } |
取得按讚 fields=likes
v2.8/1508002559485075_1820251104926884/?fields=likes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
{ "likes": { "data": [ { "id": "00000", "name": "xxxx" }, { "id": "11111", "name": "yyyyy" }, { "id": "22222", "name": "ooooo" } ], "paging": { "cursors": { "before": "ODQ0NjY5NTU1NTUwNzI5", "after": "NDExMDUyMTczODA2MwZDZD" }, "next": "https://graph.facebook.com/v2.8/1508002559485075_1820251104926884/likes?access_token=EAACEdEose0cBAPSILwOwZCMdPJZCRSoSYQg3z58zIaq86xUhVg6DeOwGVGNiDzxykh1W6sfaX4BDwg9Q2EuANZCvrpSyZAlY0jpwzLLAWtFqCXet4kBrWca2uo4LLMOw6ZCZCvHlc4o70r3MgyRTwpq8ZCiZAhWILLposhIQQIWLygZDZD&pretty=0&limit=25&after=NDExMDUyMTczODA2MwZDZD" } }, "id": "1508002559485075_1820251104926884" } |
取得分享數 fields=shares
v2.8/1508002559485075_1820251104926884/?fields=shares
1 2 3 4 5 6 |
{ "shares": { "count": 57 }, "id": "1508002559485075_1820251104926884" } |
這個數字不代表什麼,因為隱私權設定問題所以最後「看得到」都會更少,所以一般都是使用接下來介紹的 sharedposts
--
取得分享列表 sharedposts
要取得「相對完整」的資料,必須滿足
- v2.3 以前的 API
- 權限:read_stream
- 現在看到已經太晚了,APP 現在強迫在最新版 (v2.8) 所以無法使用 v2.3 的 Token 以及 read_stream 權限
v2.3/1508002559485075_1820251104926884/sharedposts?limit=2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
{ "data": [ { "created_time": "2016-11-29T14:17:24+0000", "story": "Vince Chu shared 明郅奇幻星球-Mj's post.", "actions": [ { "name": "Like", "link": "https://www.facebook.com/vince.chu.10/posts/1525881090759814" }, { "name": "Comment", "link": "https://www.facebook.com/vince.chu.10/posts/1525881090759814" }, { "name": "Share", "link": "https://www.facebook.com/vince.chu.10/posts/1525881090759814" }, { "name": "Add Friend", "link": "https://www.facebook.com/ajax/add_friend/action.php" } ], "description": "【加碼】分享數如達100人,加碼再抽5本!你分享了沒?! 明郅小星球與馨琳揚聯名發行的2017年小桌曆上市囉! 我們將在粉絲團抽獎贈送10本。 參加方法:即日起只要對本篇文章、和對我們的 明郅奇幻星球-Mj 粉絲團按讚,並分享本篇文章! 我們會在12/25號前抽出幸運的小粉絲們,贈送超級實用的星座小桌曆喔!超級可愛的內容,大家把握機會別錯過了! #2017桌曆 #明郅小星球", "from": { "name": "Vince Chu", "id": "1125295330818394" }, "is_hidden": false, "is_expired": false, "link": "https://www.facebook.com/mjapptech/photos/a.1626969754255021.1073741831.1508002559485075/1820250471593614/?type=3", "name": "明郅奇幻星球-Mj", "object_id": "1820250471593614", "picture": "https://scontent.xx.fbcdn.net/v/t1.0-0/s130x130/15085615_1820250471593614_490881572649580577_n.jpg?oh=80190419f01ecb893ff791966b73cd22&oe=58F37E2A", "privacy": { "allow": "", "deny": "", "description": "", "friends": "", "value": "" }, "status_type": "mobile_status_update", "story_tags": { "0": [ { "id": "1125295330818394", "name": "Vince Chu", "type": "user", "offset": 0, "length": 9 } ], "17": [ { "id": "1508002559485075", "name": "明郅奇幻星球-Mj", "type": "page", "offset": 17, "length": 9 } ] }, "subscribed": false, "type": "photo", "updated_time": "2016-11-29T14:17:24+0000", "id": "1125295330818394_1525881090759814" }, { "created_time": "2016-11-22T06:57:26+0000", "message": "希望我是幸運兒之一!Y(^_^)Y", "story": "Chyi Wen Jiang shared 明郅奇幻星球-Mj's post.", "actions": [ { "name": "Share", "link": "https://www.facebook.com/chyiwen.jiang/posts/1479706592042753" }, { "name": "Add Friend", "link": "https://www.facebook.com/ajax/add_friend/action.php" } ], "description": "【加碼】分享數如達100人,加碼再抽5本!你分享了沒?! 明郅小星球與馨琳揚聯名發行的2017年小桌曆上市囉! 我們將在粉絲團抽獎贈送10本。 參加方法:即日起只要對本篇文章、和對我們的 明郅奇幻星球-Mj 粉絲團按讚,並分享本篇文章! 我們會在12/25號前抽出幸運的小粉絲們,贈送超級實用的星座小桌曆喔!超級可愛的內容,大家把握機會別錯過了! #2017桌曆 #明郅小星球", "from": { "name": "Chyi Wen Jiang", "id": "1497357793610966" }, "is_hidden": false, "is_expired": false, "link": "https://www.facebook.com/mjapptech/photos/a.1626969754255021.1073741831.1508002559485075/1820250471593614/?type=3", "name": "明郅奇幻星球-Mj", "object_id": "1820250471593614", "picture": "https://scontent.xx.fbcdn.net/v/t1.0-0/s130x130/15085615_1820250471593614_490881572649580577_n.jpg?oh=80190419f01ecb893ff791966b73cd22&oe=58F37E2A", "privacy": { "allow": "", "deny": "", "description": "", "friends": "", "value": "" }, "status_type": "mobile_status_update", "story_tags": { "0": [ { "id": "1497357793610966", "name": "Chyi Wen Jiang", "type": "user", "offset": 0, "length": 14 } ], "22": [ { "id": "1508002559485075", "name": "明郅奇幻星球-Mj", "type": "page", "offset": 22, "length": 9 } ] }, "subscribed": false, "type": "photo", "updated_time": "2016-11-22T07:00:01+0000", "id": "1497357793610966_1479706592042753" } ], "paging": { "cursors": { "before": "MTUyNTg4MTA5MDc1OTgxNDo5OjAZD", "after": "MTQ3OTcwNjU5MjA0Mjc1Mzo5OjAZD" }, "next": "https://graph.facebook.com/v2.3/1508002559485075_1820251104926884/sharedposts?access_token=EAACEdEose0cBAN69opZCs7NIVbW1SoZBWhL5s9IonjSZBRqhSbmwaaCDbbXRPbwwbv7b4NcZCLPRXDIGVLmZCmZAjsS3p7LfMhmqYMYE2BH1daLlPT2wQFYsZAqZBbjl6sKkq1tdj2urO66IoOmTL5EBdTTuuPq28sYZAqZCGVdbSD0AZDZD&pretty=0&limit=2&after=MTQ3OTcwNjU5MjA0Mjc1Mzo5OjAZD" } } |
--
使用網頁 HTTP 直接取得
- Chrome F12 取得
- List of people who shared on facebook
因為是非同步取得資料,所以除了解析字串還要多次取得資料才會完整
1 |
Request URL:https://www.facebook.com/ajax/shares/view?target_fbid=1820251104926884&dpr=1&__asyncDialog=2&__user=100010043370264&__a=1&__dyn=aKhoFeyfyGmaomgDBUOWEyAzm5ucCwKAKGgS8UR9LFGA5RBxvCWzGwDzQHUF2UF7zFGxK5FFHxuqE88HyWDyUJi28yuaxuAUWVpenKtojKeyVohWxaFS789FQibVop-qidGl4hQmexvDAzUO49epyby46o-Elx2qF9QiFu9x2bBzEF6AwBglBDyFLZ3VdbggKmcy8CEmJ5p8F12l7m8-5elG9DAAACBRUlG&__af=i0&__req=e&__be=-1&__pc=EXP1%3ADEFAULT&__rev=2723614&ft[tn]=]&ft[top_level_post_id]=1820251104926884&ft[tl_objid]=1820251104926884&ft[fbfeed_location]=86 |
對於公開的粉絲專頁,可以簡化為
1 |
https://www.facebook.com/ajax/shares/view/?target_fbid=1820251104926884&__a=1 |
--
看 Post 文轉貼
https://www.facebook.com/shares/view?id=1820251104926884
--
v2.3/1820251104926884?fields=likes.limit(1000),sharedposts.limit(1000)
1 2 3 4 |
for ($i = 0; $i <= 31; ++$i) { $checkLogin = str_replace(chr($i), "", $checkLogin); } $checkLogin = str_replace(chr(127), "", $checkLogin); |
--
取得使用者資訊
https://www.facebook.com/app_scoped_user_id/使用者 id
v2.3/me
1 2 3 4 5 6 7 8 9 10 11 12 |
{ "id": "10152133038800765", "first_name": "志賢", "gender": "male", "last_name": "黃", "link": "https://www.facebook.com/app_scoped_user_id/10152133038800765/", "locale": "zh_TW", "name": "黃志賢", "timezone": 8, "updated_time": "2016-08-30T16:05:32+0000", "verified": true } |
--
內嵌 Post 文
1 |
https://www.facebook.com/plugins/post.php?href=https://www.facebook.com/mjapptech/posts/1820251104926884&locale=zh_TW&width=750 |
--
4,314 total views, 1 views today