'facebook-php-business-sdk getting PHP Fatal error: Uncaught FacebookAds\Http\Exception\AuthorizationException: Invalid parameter in targeting

PHP Fatal error: Uncaught FacebookAds\Http\Exception\AuthorizationException: Invalid parameter in C:\xampp8.0\htdocs\facebook-php-business-sdk\src\FacebookAds\Http\Exception\RequestException.php:174 Stack trace:

$params = array(
  'name' => 'My First AdSet',
  'daily_budget' => '4000',
  'bid_amount' => '300',
  'billing_event' => 'IMPRESSIONS',
  'optimization_goal' => 'REACH',
  'campaign_id' => $campaign_id,
  'promoted_object' => array('page_id' => $page_id),
  'targeting' => array('facebook_positions' => array('feed'),'geo_locations' => array('countries' => array('US'),'regions' => array(array('key' => '4081')),'cities' => array(array('key' => 777934,'radius' => 10,'distance_unit' => 'mile'))),'genders' => array(1),'age_max' => 24,'age_min' => 20,'publisher_platforms' => array('facebook','audience_network'),'device_platforms' => array('mobile'),'flexible_spec' => array(array('interests' => array(array('id' => '6003139266461','name' => 'Movies'))))),
  'status' => 'PAUSED',
);
$ad_set = (new AdAccount($ad_account_id))->createAdSet(
  $fields,
  $params
);
$ad_set_id = $ad_set->id;
echo 'ad_set_id: ' . $ad_set_id . "\n\n";


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source