PHP code example of spotonlive / laravel-facebook-ads

1. Go to this page and download the library: Download spotonlive/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/ */

    

spotonlive / laravel-facebook-ads example snippets




namespace App\Http\Controllers;

use LaravelFacebook\Clients\Facebook;

class AdsController
{
    /** @var Facebook */
    protected $facebookClient;

    public function __construct(Facebook $facebookClient)
    {
        $this->facebookClient = $facebookClient;
    }

    /**
     * Show ads
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function ads()
    {
        $client = $this->facebookClient;

        $accountId = 'act_12345678';

        return view('ads', [
            'ads' => $client->account($accountId)->ads(),
        ]);
    }
}