I have created a Laravel app in which I am integrated meta API as shown below.
$this->client = new Client([
'base_uri' => 'https://graph.facebook.com/',
]);
$endpoint = "v20.0/{$this->adAccountId}/insights";
$params = [
'access_token' => $this->accessToken,
'fields' => 'spend,created_time',
'level' => 'ad',
'TIME_INCREMENT' => 'day',
];
$response = $this->client->get($endpoint, [
'query' => $params
]);
Above code is working fine. Now I need a meta Webhook which give me data of whenever client spend on Facebook ads. and I don’t know whet to do next.
I have created a Webhook using below code
$client = new Client([
'base_uri' => 'https://graph.facebook.com',
]);
$endpoint = '/v20.0/APPID/subscriptions?access_token='.$accessToken;
$response = $client->post($endpoint, [
'object' => 'page',
'callback_url' => $callbackUrl,
'fields' => 'leadgen',
'verify_token' => $verifyToken
]);
I tried above code but it show error on Oouth. I also tried to give APPID|APP_SECRET
. It also give errorOAuthException. I also used same code in graph API explorer.
Sonam Dhami is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.