指南

本指南說明社團 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"
    }
  ]
}

限制

  • 呼叫只會傳回最近 90 天內建立的貼文資料。

取得分享公開欄位的用戶

您可以在 /{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"
    }
  ]
}

取得安裝/解除安裝應用程式之社團的 Webhooks

您可以在 Application 物件上訂閱 group_install 欄位,當社團成員在社團中安裝或解除安裝應用程式時,您就會收到 Webhook 通知。

通知範例

{
  "field": "group_install",
  "value": {
    "group_id": "954704787945183",
    "update_time": "1527459824",
    "verb": "add",
    "actor_id": "499619301"
  }
}