Git Product home page Git Product logo

laravel-facebook-ads's Introduction

logo

Laravel Facebook Ads

Get ads infos (campaigns, ads, insights, etc...) from Facebook & Instagram Ads API

  • Supported Facebook API version: >= v3.0

Packagist Code Climate Codacy Badge StyleCI Packagist


Installation

Follow this steps to use this package on your Laravel installation

Installing with composer

composer require edbizarro/laravel-facebook-ads

The package will automatically register it's service provider.

For Laravel <= 5.4 add the provider manually

Load service provider (optional Laravel <= 5.4 only)

You need to update your config/app.php configuration file to register our service provider, adding this line on providers array:

Edbizarro\LaravelFacebookAds\Providers\LaravelFacebookServiceProvider::class

Enable the facade (optional)

This package comes with an facade to make the usage easier. To enable it, add this line at config/app.php on alias array:

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

Configuration

If you want to change any configurations, you need to publish the package configuration file. To do this, run artisan vendor:publish --provider="Edbizarro\LaravelFacebookAds\Providers\LaravelFacebookServiceProvider" on terminal. This will publish a facebook-ads.php file on your configuration folder like this:

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

Note that this file uses environment variables, it's a good practice put your secret keys on your .env file adding this lines on it:

FB_ADS_APP_ID="YOUR_APP_ID"
FB_ADS_APP_SECRET="YOUR_APP_SECRET_KEY"

First steps

Before using it, it's necessary to initialize the library with an valid access token, php example with:

FacebookAds::init($accessToken);

Now that everything is set up, it's easy to start using!

Example getting all ads

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

Usage

To obtain a list of all AdAccount available fields, look at this.

adAccounts

To obtain an adAccounts instance:

$adAccounts = $adsApi->adAccounts();

all

Use this method to retrieve your owned Ad Accounts. This method accepts an array as argument containing a list of fields.

To obtain a list of all available fields, look at this.

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

get

Use this method to get details of an AdAccount. This method accepts an array as argument containing a list of fields and an account_id act_<AD_ACCOUNT_ID>

To obtain a list of all available fields, look at this.

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

Campaigns

To obtain an Campaigns instance:

$campaigns = $adsApi->campaigns();

all

Use this method to retrieve your adAccount campaigns. This method accepts an array as argument containing a list of fields and an account_id act_<AD_ACCOUNT_ID>

To obtain a list of all available fields, look at this.

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

License

FOSSA Status

laravel-facebook-ads's People

Contributors

andrei930 avatar braunson avatar dependabot-preview[bot] avatar dependabot[bot] avatar edbizarro avatar fossabot avatar iget-esoares avatar mauricioa0 avatar scrutinizer-auto-fixer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.