I'm currently trying to get Facebook to send all potential customers, as they are registered in real time for a subscribed endpoint. Facebook mentions in its documentation that this is possible by setting up a real-time update from a new ad campaign.
https://developers.facebook.com/docs/marketing-api/guides/lead-ads/v2.5#setting-up-realtime-updates
However, after a few hours, trying to integrate this, I could not get it to work. Below is a process that I have followed so far to no avail.
Application setup
I created the Facebook application (423332064458136), which is currently tied to my personal account. This application works live, but does not work on any platform, as it does not require approval through a review (as I understand it).
I registered a callback for this application using the application id and 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 got a response {success: true} after registering. To confirm this, in place, using the application token from the GraphAPI explorer, I ran the request along the following path:
/ 423332064458136 / subscriptions
And got the answer:
{ "data": [ { "object": "page", "callback_url": "https://leadr.co.uk/external/handle-fb.php", "fields": [ "leadgen" ], "active": true } ], }
In the place https://leadr.co.uk/external/handle-fb.php I respond with hub_challenge, if necessary, and additionally registers everything that is sent via php: // input to a text file.
Set up lead ad
I installed a lead ad on the VoucherSelector page ( https://www.facebook.com/permalink.php?story_fbid=1009785315719107&id=140148862682761 ) using the instructions from the Facebook documentation: https://developers.facebook.com/docs/marketing-api /guides/lead-ads/v2.5 .
This parameter is currently inactive, since we do not want to spend any expenses on it at this stage of testing. However, he realized that accounts can still be registered using this URL (see above).
Then we signed this page to our application using the page access token. Using the graphAPI explorer, I selected our application and then received the page access token for the voucher page. Then I ran the following request to subscribe to a page in our application.
curl \ -F "access_token=<PAGE_ACCESS_TOKEN>" \ "https://graph.facebook.com/v2.5/140148862682761/subscribed_apps"
I got the {success: true} response from this. By running a GET request on the same endpoint, I get the answer 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" } ], }
Confirmation that the page is subscribed to our application.
At any time when registration is registered in this lead announcement, our endpoint does NOT end up in any payload.
Additional notes
- I am the administrator of the voucher selection page that keeps ads running.
- When I try to download tooltips created from this ad (of which there are currently 8), I only get myself in the download file.
Any attempt to use the / subscriptions _sample endpoint to send a test packet to our endpoint fails with the following error (this means that we are limited only by the ability to test using real accounts):
{"error": {"message": "(# 3) The application must be whitelisted", "type": "OAuthException", "code": 3, "fbtrace_id": "HH5gInxafKP"}}
The view was stuck on how to get out of here. Has anyone had any success in sending this ad to the endpoint of the subscription?