What is the authorization for reach and frequency campaign?
1

I was tasked with fetching estimates for cost per click, impressions, reach, total spend, etc. I'm trying to use the reachfrequencyprediction API, but after I execute the request I get the following error:

You do not have permission to run a reach and frequency campaign.

I tried searching on Facebook Ads Documentation but didn't find the permission you need to have to use it.

I've read the restrictions on using this feature https://developers.facebook.com/docs/marketing-api/reachandfrequency/#restrictions and I don't seem to have any issues with that.

I've attached my code, maybe I'm doing something wrong.

/** * Method that creates the campaign and returns its id * Finally these estimates will be saved through the controller ReportController@store_meta */ public function crea_simulazione(StoreMetaReportRequest $request) {

echo "<pre>";
// var_dump($request->all());die;

$campaign = new Campaign(null, $this->account->id);
$campaign->setData([
    CampaignFields::NAME => "Campagna " . uniqid(),
    CampaignFields::OBJECTIVE => $request->input('obiettivo'),
    CampaignFields::SPECIAL_AD_CATEGORIES => array(),
]);
$campaign->create([
    Campaign::STATUS_PARAM_NAME => Campaign::STATUS_PAUSED
]);

echo "Campagna creata: " . $campaign->id . "\n";

$fieldsAdSet = [
    'name' => "Ad Set " . uniqid(),
    'type_budget' => $request->input('type_budget'),
    'budget' => $request->input('importo'),
    'targeting' => $request->input('tags'),
    'luogo' => $request->input('paese_ads'),
    'age_min' => $request->input('min_eta'),
    'age_max' => $request->input('max_eta'),
    'start_ads' => $request->input('start_ads'),
    'end_ads' => $request->input('end_ads'),
    'genere' => $request->input('genere'),
    'page_id' => $request->input('pagina_facebook'),
    'billing_event' => $request->input('obiettivo'),
    'opt_goal' => $request->input('optimization_goal'),
    'country_code' => $request->input('country_ads'),
    'region_code' => $request->input('region_ads'),
    'tags_values' => $request->input('tags_values')
];
$tags = [];
foreach ($fieldsAdSet['tags_values'] as $key => $value) {
    $tags[] = ['id' => $value['id'], 'name' => $value['value']];
}

$fields = array(
    AdSetFields::NAME => $fieldsAdSet['name'],
    // AdSetFields::OPTIMIZATION_GOAL => $fieldsAdSet['billing_event'],
    // AdSetFields::BILLING_EVENT => $fieldsAdSet['opt_goal'],
    //inserisco questi due però sono da togliere e sostituire con quello che viene fornito da fronted.
    AdSetFields::OPTIMIZATION_GOAL => AdSetOptimizationGoalValues::REACH,
    AdSetFields::BILLING_EVENT => AdSetBillingEventValues::IMPRESSIONS,
    AdSetFields::BID_AMOUNT => 2,
    AdSetFields::DESTINATION_TYPE => AdSetDestinationTypeValues::WEBSITE,
    AdSetFields::DAILY_BUDGET => intval($fieldsAdSet['budget']) * 100,
    AdSetFields::CAMPAIGN_ID => $campaign->id,
    AdSetFields::TARGETING => (new Targeting())->setData(array(
        TargetingFields::GEO_LOCATIONS => array(
            'cities' => array(
                array(
                    'key' => '1188733',
                    'radius' => 20,
                    'distance_unit' => 'kilometer'
                ),
            ),
        ),
        TargetingFields::USER_OS => array('iOS', 'Android', 'Windows'),
        TargetingFields::INTERESTS => $tags,
        TargetingFields::AGE_MIN => $fieldsAdSet['age_min'],
        TargetingFields::AGE_MAX => $fieldsAdSet['age_max'] - 20,
        TargetingFields::GENDERS => $fieldsAdSet['genere'] == 'all' ? [1, 2] : [$fieldsAdSet['genere']]
    )),
);

/** * I define the type of campaign. * If the budget type is daily then the spending limit that Facebook will set is daily with the aim of keeping it lower and lower. * While if it's lifetime you're telling Facebook to optimize the AdSet to get the lowest possible cost without daily budget limits. */ if ($fieldsAdSet['type_budget'] == 'day') { $fields[AdSetFields::DAILY_BUDGET] = $fieldsAdSet['budget'] * 100; // Converto in centesimi perché altrimenti non lo accetta $fields[AdSetFields::BID_STRATEGY] = AdSetBidStrategyValues::LOWEST_COST_WITH_BID_CAP; } else if ($fieldsAdSet['type_budget'] == 'lifetime') { $fields[AdSetFields::BID_AMOUNT] = $fieldsAdSet['budget'] * 100; // Converto in centesimi perché altrimenti non lo accetta $fields[AdSetFields::BID_STRATEGY] = AdSetBidStrategyValues::LOWEST_COST_WITHOUT_CAP; }

$this->reachfrequency($fieldsAdSet['billing_event'],$fields,$campaign->id);
echo "End reach frequency\n";
die;

} public function reachfrequency($obbiettivo,$arr,$idCamapagna) { $a = [ 'budget' => $arr[AdSetFields::DAILY_BUDGET], 'day_parting_schedule' => [[ 'start_minute' => 360, 'end_minute' => 1440, 'days' => array(0, 1, 2, 3, 4, 5, 6) ]], 'destination_id' => "1730870867215691", // Page id - Brain computing 'frequency_cap' => 2, 'interval_frequency_cap_reset_period' => 48, 'objective' => $obbiettivo, 'optimization_goal' => $arr[AdSetFields::OPTIMIZATION_GOAL], 'prediction_mode' => 1, 'reach' => 1000000, 'start_time' => (new DateTime('+1 day'))->getTimestamp(), 'end_time' => (new DateTime('+8 day'))->getTimestamp(), 'target_spec' => [ 'geo_locations' => [ 'countries' => ['IT'], ], 'age_min' => 18, 'age_max' => 65, ], 'campaign_group_id' => $idCamapagna, ]; $esito = Api::instance()->call('/' . env('FACEBOOK_ACCOUNT_ID_SANBOX') . "/reachfrequencypredictions", RequestInterface::METHOD_POST, $a); var_dump($esito); die; }

I'm using a SandBox account, could this be why?

Dev
Asked about 11 months ago