facebook – Business SDK Features for Conversions API in WordPress website

I am trying to integrate CAPI or Conversion API within my WordPress site in custom mode via PHP and to do so I am following the following guide:

I have downloaded the library under a directory in my wp-content and I am using PHP version 7.3.27.

I am getting the following problem though:

Fatal error: Uncaught Error: Class
‘FacebookAdsObjectServerSideEventRequestAsync’ not found in

UPDATED: I was able to fix this error, I saw that the dependency was missing. The composer command was not correctly installing all the dependencies I needed. Now I have installed everything, but I get this error in return:

Fatal error: Uncaught Error: Class ‘ActionSource’ not found in…

The code I’m using is the following, which is virtually identical to the code shown in the guide:

require __DIR__ . '/dotenv/vendor/autoload.php';
require __DIR__ . '/facebookAPI/vendor/autoload.php';

$dotenv = DotenvDotenv::createImmutable(__DIR__);

use FacebookAdsApi;
use FacebookAdsObjectServerSideCustomData;
use FacebookAdsObjectServerSideEvent;
use FacebookAdsObjectServerSideEventRequest;
use FacebookAdsObjectServerSideEventRequestAsync;
use FacebookAdsObjectServerSideUserData;

use GuzzleHttpExceptionRequestException;
use GuzzleHttpPromise;

$pixel_id = $_ENV("PIXEL_ID");
$access_token = $_ENV("ACCESS_TOKEN");

if (empty($pixel_id) || empty($access_token)) {
  throw new Exception('Missing required test config. Got pixel_id: "' . $pixel_id . '", access_token: "' . $access_token . '"');

Api::init(null, null, $access_token, false);

function create_events($num) {
  $user_data = (new UserData())
    ->setEmail('joe' . $num . '@eg.com')

  $custom_data = (new CustomData())

  $event = (new Event())

  return array($event);

function create_async_request($pixel_id, $num) {
  $async_request = (new EventRequestAsync($pixel_id))
  return $async_request->execute()
      function (RequestException $e) {
          "Error!!!n" .
          $e->getMessage() . "n" .
          $e->getRequest()->getMethod() . "n"

// Async request:
$promise = create_async_request($pixel_id, 2);

print("Request 1 state: " . $promise->getState() . "n");
print("Async request - OK.n");

// Async request with wait:
$promise = create_async_request($pixel_id, 3);

$response2 = $promise->wait();
print("Request 2: " . $response2->getBody() . "n");
print("Async request with wait - OK.n");

// Multiple async requests:
$promises = (
  "Request 3" => create_async_request($pixel_id, 4),
  "Request 4" => create_async_request($pixel_id, 5),

$response3 = Promiseunwrap($promises);
foreach ($response3 as $request_name => $response) {
  print($request_name . ": " . $response->getBody()."n");
print("Async - Multiple async requests OK.n");

Where is the problem? Thank you very much to those who will help me!

RESOLVED: I’ve realized that it’s almost all dependency issues. I’m proceeding as I go along. Thanks anyway! 🙂