本指南介紹了群組 API 的常見用途。
您可在 /{group-id}/feed
關係連線執行 GET
操作來獲取群組帖子。
在預設情況下,此回應不包含個人識別資料。如要在回應中包含帖子作者公開的可用資訊,帖子作者必須向您的應用程式授予 groups_access_member_info
權限。
curl -i -X GET \ "https://graph.facebook.com/{group-id}/feed?limit=5&access_token=EAACEdEos0..."
此回應範例省略了個人識別資料。
{ "data": [ { "message": "I love this group!", "updated_time": "2018-06-28T23:31:49+0000", "id": "554611227955614_1708186035931455" //Post ID }, { "message": "I like how linked groups look on mobile!", "updated_time": "2018-06-14T23:19:02+0000", "id": "554611227955614_1687969857953073" //Post ID } ] }
帖子作者向您的應用程式授予 groups_access_member_info
權限的回應範例。
{ "data": [ { "from": { "name": "Himanshu Sharma", "id": "512130107215" }, "message": "I love this group!", "id": "554611227955614_1708186035931455" }, { "from": { "name": "Ronak Patel", "id": "512130107214" }, "message": "Just testing how linked groups look like on mobile!", "id": "554611227955614_1687969857953073" } ] }
您可在 /{group-id}/opted_in_members
關係連線執行 GET
操作,以取得已向您應用程式授予 groups_access_member_info
權限的群組成員用戶名單。這些群組成員已選擇向群組上安裝的應用程式分享其公開的可用資訊。
curl -i -X GET \
"https://graph.facebook.com/{group-id}/opted_in_members&access_token=EAACEdEos0..."
{ "data": [ { "name": "Himanshu Sharma", "id": "510765591715" }, { "name": "Ronak Patel", "id": "410662391314" } ] }
您可訂閱 Application
物件上的 group_install
欄位,從而在群組成員於群組中安裝或解除安裝您的應用程式時取得 Webhook 通知。
{ "field": "group_install", "value": { "group_id": "954704787945183", "update_time": "1527459824", "verb": "add", "actor_id": "499619301" } }