I'm trying to send a ViewContent
event thru the Meta Conversions API. I went to the account's pixel, generated an access token in the Events Manager, then sent the event using the PHP SDK.
When I send the event, I get this error where XXXXXXXXXXXXXXX is my pixel ID:
FacebookAds\Http\Exception\AuthorizationException: Unsupported post request. Object with ID 'XXXXXXXXXXXXXXX' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api in /vendor/facebook/php-business-sdk/src/FacebookAds/Http/Exception/RequestException.php:174
Stack trace:
#0 /vendor/facebook/php-business-sdk/src/FacebookAds/Http/Client.php(226): FacebookAds\Http\Exception\RequestException::create()
#1 /vendor/facebook/php-business-sdk/src/FacebookAds/Http/Request.php(286): FacebookAds\Http\Client->sendRequest()
#2 /vendor/facebook/php-business-sdk/src/FacebookAds/Api.php(165): FacebookAds\Http\Request->execute()
#3 /vendor/facebook/php-business-sdk/src/FacebookAds/Api.php(214): FacebookAds\Api->executeRequest()
#4 /vendor/facebook/php-business-sdk/src/FacebookAds/ApiRequest.php(187): FacebookAds\Api->call()
#5 /vendor/facebook/php-business-sdk/src/FacebookAds/Object/AdsPixel.php(230): FacebookAds\ApiRequest->execute()
#6 /vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/EventRequest.php(285): FacebookAds\Object\AdsPixel->createEvent()
#7 /vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/EventRequest.php(277): FacebookAds\Object\ServerSide\EventRequest->defaultExecute()
#8 /vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/EventRequest.php(247): FacebookAds\Object\ServerSide\EventRequest->sendToCAPIEndpoint()
#9 /app/Services/Tracking/Facebook/ApiClient.php(33): FacebookAds\Object\ServerSide\EventRequest->execute()
#10 /app/Services/Tracking/Facebook/ViewContent.php(66): App\Services\Tracking\Facebook\ApiClient->sendEvent()
I've implemented this before with a Facebook app but this is the first time not using an app and only using an access token. I followed the PHP documentation for doing this without an app setup: https://developers.facebook.com/docs/marketing-api/conversions-api/using-the-api/
This is the contents of my API client code that actually sends the event:
class ApiClient
{
public function __construct()
{
Api::init(null, null, config('facebook.access_token'), false);
}
public function sendEvent(Event $event): void
{
(new EventRequest(config('services.facebook.pixel_id')))
->setTestEventCode(config('services.facebook.test_event_code'))
->setEvents([$event])
->execute();
}
}
Again, this code works fine when I am connecting to an account with an app, but does not work when just using an access token and gives the error above.
I've tried this exact same request using the Graph API Explorer tool and I get the exact same error.
Any idea what's wrong here?