I'm currently attempting to get Facebook to send over all leads as they're registered in real time to a subscribed endpoint. Facebook mentions in their documentation that this is possible by setting up a realtime update from the new lead ads service.
https://developers.facebook.com/docs/marketing-api/guides/lead-ads/v2.5#setting-up-realtime-updates
However after several hours trying to integrate this this, I've failed to get it to work. Below is the process I've followed so far to no avail.
Setting up the application
I've set up a Facebook application (423332064458136) which is currently tied to my personal account. This application is live, but isn't operating on any platform, as such doesn't require approval through review (as far as I understand).
I've registered a leadgen callback for this application using both the application ID and the application secret. This was achieved using the following curl request..
curl \
-F "object=page" \
-F "callback_url=https://leadr.co.uk/external/handle-fb.php" \
-F "fields=leadgen" \
-F "verify_token=abc123" \
-F "access_token=423332064458136|<APP_SECRET>" \
"https://graph.facebook.com/v2.5/423332064458136/subscriptions"
I received a {success:true} response after registering this. To confirm this is in place, using an application token from the GraphAPI explorer I ran a request at the following path:
/423332064458136/subscriptions
And received back a response of:
{
"data": [
{
"object": "page",
"callback_url": "https://leadr.co.uk/external/handle-fb.php",
"fields": [
"leadgen"
],
"active": true
}
],
}
At the location https://leadr.co.uk/external/handle-fb.php I'm responding with a hub_challenge if required, and additionally logging everything that is sent through php://input to a text file.
Setting up the lead ad
I've setup a lead ad on the VoucherSelector page (https://www.facebook.com/permalink.php?story_fbid=1009785315719107&id=140148862682761) using the instruction from the Facebook documentation: https://developers.facebook.com/docs/marketing-api/guides/lead-ads/v2.5.
This is currently set to inactive as we don't want to spend any budget on it during this testing phase. However it's understood that accounts can still register using the given URL (above).
We've then subscribed this page to our application using a page access token. Using the graphAPI Explorer I've selected our application, and then got a page access token for the voucherselector page. I've then run the following request to subscribe the page to our application.
curl \
-F "access_token=<PAGE_ACCESS_TOKEN>" \
"https://graph.facebook.com/v2.5/140148862682761/subscribed_apps"
I received a {success:true} response from doing this. By running a GET request at the same endpoint I receive a response as follows:
{
"data": [
{
"category": "Business",
"link": "https://www.facebook.com/games/?app_id=423332064458136",
"name": "leadR - Lead Ads Collection",
"id": "423332064458136"
},
{
"category": "Utilities",
"link": "https://www.facebook.com/games/?app_id=2373072738",
"name": "Discussion Boards",
"id": "2373072738"
}
],
}
Confirming that the page is subscribed to our app.
Anytime a registration occurs on this lead ad, our end point is NOT being hit with any payloads.
Additional Notes
- I am an administrator of the voucher selector page, which the lead ads is running on.
- When I attempt to download leads generated from this ad (of which there are currently 8), I only receive myself in the download file.
Any attempt to use the /subscriptions_sample endpoint to sent a test packet to our endpoint fails with the following error (meaning we're limited to only being able to test with live accounts):
{"error":{"message":"(#3) App must be on whitelist","type":"OAuthException","code":3,"fbtrace_id":"HH5gInxafKP"}}
Kind of stuck on how to proceed from here. Has anyone had any success in having this send over leads ads to a subscribed endpoint?