i am integrating facebook marketing api and when i call to the function which contains code for creating facebook campaign but i am getting below exception "An Api instance must be provided as argument or set as instance in the \FacebookAds\Api". below is the function where exceptions occur
protected static function assureApi(Api $instance = null) {
$instance = $instance ?: Api::instance();
if (!$instance) {
throw new \InvalidArgumentException(
'An Api instance must be provided as argument or '.
'set as instance in the \FacebookAds\Api');
}
return $instance;
}
You must init Facebook Ads Api first:
// Add to header of your file
use FacebookAds\Api;
// Initialize a new Session and instantiate an API object
Api::init(
'1863496587233765', // App ID
'{your-app-secret}',
$_SESSION['facebook_access_token'] // Your user access token
);
Then, you can start using the Api as you are.