PHP code example of edbizarro / laravel-facebook-ads

1. Go to this page and download the library: Download edbizarro/laravel-facebook-ads library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

edbizarro / laravel-facebook-ads example snippets


Edbizarro\LaravelFacebookAds\Providers\LaravelFacebookServiceProvider::class

'FacebookAds' => Edbizarro\LaravelFacebookAds\Facades\FacebookAds::class


return [
    'app_id' => env('FB_ADS_APP_ID'),
    'app_secret' => env('FB_ADS_APP_SECRET'),
];

FacebookAds::init($accessToken);

$ads = FacebookAds::adAccounts()->all()->map(function ($adAccount) {
  return $adAccount->ads(
      [
          'name',
          'account_id',
          'account_status',
          'balance',
          'campaign',
          'campaign_id',
          'status'
      ]
  );
});

$adAccounts = $adsApi->adAccounts();

$adAccounts->all(['account_id', 'balance', 'name']);

$adAccounts->get(['account_id', 'balance', 'name'], 'act_<AD_ACCOUNT_ID>');

$campaigns = $adsApi->campaigns();

$campaigns->all(['name'], 'act_<AD_ACCOUNT_ID>');