이 가이드에서는 Webhooks를 사용하여 고객 관계 관리 목적의 잠재 고객용 광고를 위한 Meta Webhooks를 구현하는 방법을 설명합니다.
앱 사용자가 Facebook 로그인을 사용하여 앱에 로그인하고, 잠재 고객용 Meta Webhooks를 구독하는 Facebook 페이지에 필요한 권한을 앱에 부여합니다. Facebook 로그인은 앱 사용자가 Meta에서 서버로 보내는 잠재 고객 알림을 확인할 수 있도록 필요한 권한이 있는 페이지 액세스 토큰을 반환합니다.
다음과 같은 항목이 필요합니다.
ADVERTISE
작업을 수행할 수 있는 앱 사용자, 고객 또는 광고주의 페이지 액세스 토큰pages_read_engagement
pages_manage_metadata
pages_show_list
ads_management
lead_retrieval
Webhooks for Leads can send you real-time notifications of changes to your Page's Lead ads. For example, you can receive real-time updates whenever users click on a lead ad.
First, set up a Page Webhook:
Follow our Getting Started guide to create your endpoint and configure the Webhooks product. During configuration, make sure to choose the Page object and subscribe to the leadgen field.
Webhook notifications will only be sent if your Page has installed your Webhooks configured-app, and if the Page has not disabled the App platform in its App Settings. To get your Page to install the app, have your app send a POST
request to the Page's subscribed_apps edge using the Page's acccess token.
leads_retrieval
pages_manage_metadata
pages_show_list
pages_read_engagement
ads_management
Formatted for clarity
curl -i -X POST "https://graph.facebook.com/{page-id}/subscribed_apps ?subscribed_fields=leadgen &access_token={page-access-token}"
{ "success": "true" }
To see which app's your Page has installed, send a GET
request instead:
Formatted for clarity
curl -i -X GET "https://graph.facebook.com/{page-id}/subscribed_apps ?access_token={page-access-token}
{ "data": [ { "category": "Business", "link": "https://my-clever-domain-name.com/app", "name": "My Sample App", "id": "{page-id}" } ] }
If your Page has not installed any apps, the API will return an empty data set.
If you don't want to install your app programmatically, you can easily do it with the Graph API Explorer instead:
pages_manage_metadata
permission. This will exchange your app token for a User access token with the pages_manage_metadata
permission granted.GET
dropdown menu and selecting POST
.me?fields=id,name
query with the Page's id followed by /subscribed_apps?subscribed_fields=leadgen
, then submit the query. Your app can subscribe to a Page's Leads and get notified anytime a change occurs. For example, here's a notification sent when a User clicked on a lead ad.
{ "object": "page", "entry": [ { "id": 153125381133, "time": 1438292065, "changes": [ { "field": "leadgen", "value": { "leadgen_id": 123123123123, "page_id": 123123123, "form_id": 12312312312, "adgroup_id": 12312312312, "ad_id": 12312312312, "created_time": 1440120384 } }, { "field": "leadgen", "value": { "leadgen_id": 123123123124, "page_id": 123123123, "form_id": 12312312312, "adgroup_id": 12312312312, "ad_id": 12312312312, "created_time": 1440120384 } } ] } ] }
leadgen_id
from the notification to retrieve data associated with the leads.