问题
I have admin access on one page, I have created facebook app and created and verified webhook on my website.
The problem is that I can't get any data from facebook after my action. I created page and user webhook, then I created php script which will log any time facebook tries to reach that page. Now I can see facebook is calling that page, but I can't get any data from that call. I have printed content of POST but it is giving me value "1".
Also, there is no configuration with which I can set which facebook page I need to track. How can I set it?
回答1:
I have printed content of POST but it is giving me value "1".
Facebook does not send the data as a “normal” POST request, it sends JSON directly. Therefor PHP will not populate $_POST – you need to read the raw response body directly, and then decode it.
file_get_contents('php://input')
, and then json_decode
.
Also, there is no configuration with which I can set which facebook page I need to track. How can I set it?
You need to subscribe your app to the page to receive updates, see https://developers.facebook.com/docs/graph-api/reference/page/subscribed_apps
来源:https://stackoverflow.com/questions/35999627/facebook-webhook-for-pages