This library provides an objected-oriented wrapper of the PHP classes to send CRM Integration with Facebook API
composer require silici0/facebook-api:dev-master
php artisan vendor:publish --provider="silici0\FacebookApi\FacebookApiServiceProvider"
You need pixel_id and acesss_token to update your .env file with the follow options:
FACEBOOK_PIXEL_ID='ID'
FACEBOOK_ACCESS_TOKEN='TOKEN'
Get your event test code and fill like the example below:
use silici0\FacebookApi;
$fb = new \FacebookApi();
$response = $fb::sendTest('TEST57893');
$msg = $response->getMessages();
$eventsReceived = $response->getEventsReceived();
$fbTraceId = $response->getFbTraceId();
To send CRM Integration you need send a Deduplication hash as event ID, so facebook can identify your browser pixel with your server Pixel:
$fb = new \FacebookApi();
$data[] = array(
'user' => array(
'id' => '1',
'email' => '[email protected]',
'first_name' => 'rafael',
'phone' => '1155994267171'
),
'custom' => array(
'lead_event_source' => 'In-house CRM',
'event_source' => 'crm'
),
'event' => array(
'name' => 'Evento Lead',
'unixtimestamp' => time(),
'id' => Hash::make('[email protected]')
)
);
$response = $fb::sendCRM($data);
foreach ($response as $key => $value) {
print("<pre>".print_r($value,true)."</pre>");
}