Getting invalid parameter response when creating geo_locations targeting spec in the Facebook Marketing api

3.1k views Asked by At

I am trying to add cities to my geo_location targeting in a facebook marketing api call.

$targeting_spec = array(
            'geo_locations' => [
                'countries' => ['US'],
                'cities' =>
                    ['key' => '2490299','radius' => 10, 'distance_unit' => 'mile']
            ],

            'age_min' => 13,

        );

My code above seems like it should be correct, especially after looking at the docs here. However I get the following error:

{"error":{"message":"Invalid parameter","type":"OAuthException","code":100,"error_subcode":1487079,"is_transient":false,"error_user_title":"Invalid Targeting Spec","error_user_msg":"The specified targeting spec is not valid because: Invalid data for field geo_locations. Invalid Targeting Spec: The specified targeting spec is not valid because: Normalization expecs a KeyedTraversable. TAAL[BLAME_file]\n","fbtrace_id":"HwU9EMDTah1"}}

It seems to be saying there's something invalid about my geo_locations field but I have no idea what that could be. Any ideas? Thank you.

1

There are 1 answers

1
maplater On

For any lost souls who end up here I figured out what was wrong. The correct targeting is below:

$targeting_spec = array(
            'geo_locations' => [
                'cities' =>
                    array(['key' => '2490299','radius' => 10, 'distance_unit' => 'mile'])
            ],

            'age_min' => 13,

        );