Доброе утро всем, ребят подскажите пожалуйста почему при отправке многомерного массива обработчик говорит что это не массив -_-
ЗАПРОС:
function createAdSetCliks($id,$campaign_id, $token, $curl) {
$data = array(
'name' => 'AdSet_HUY',
'daily_budget' => '50000',
'start_time' => '2020-04-17T22:23:07-0700',
'end_time' => '0',
'bid_strategy' => 'LOWEST_COST_WITHOUT_CAP',
'billing_event' => 'IMPRESSIONS',
'optimization_goal' => 'LINK_CLICKS',
'campaign_id' => $campaign_id,
'targeting' => array(
'geo_locations' => array(
'countries' => 'FR'
),
),
'promoted_object ' => array(
'custom_event_type' => 'LEAD',
'pixel_id' => '2656807074586628'
),
'status' => 'PAUSED',
'access_token' => $token,
);
$curl->setDefaultJsonDecoder($assoc = true);
$curl->setHeader('Content-Type', 'application/json');
$curl->post('https://graph.facebook.com/v7.0/'.$id.'/adsets', $data);
echo "<pre>";
var_dump($curl->response);
echo "</pre>";
}
Ответ:
array(3) {
["error"]=>
array(4) {
["message"]=>
string(66) "(#100) param targeting[geo_locations][countries] must be an array."
["type"]=>
string(14) "OAuthException"
["code"]=>
int(100)
["fbtrace_id"]=>
string(23) "AqOHv3y1F3dyikGNIXHQtuR"
}
["__fb_trace_id__"]=>
string(11) "BC3y2mLbv7u"
["__www_request_id__"]=>
string(23) "AqOHv3y1F3dyikGNIXHQtuR"
}
Использую класс:
php-curl-class
var_dump($data)
array(12) {
["name"]=>
string(9) "AdSet_HUY"
["daily_budget"]=>
string(5) "50000"
["start_time"]=>
string(24) "2020-04-17T22:23:07-0700"
["end_time"]=>
string(1) "0"
["bid_strategy"]=>
string(23) "LOWEST_COST_WITHOUT_CAP"
["billing_event"]=>
string(11) "IMPRESSIONS"
["optimization_goal"]=>
string(11) "LINK_CLICKS"
["campaign_id"]=>
NULL
["targeting"]=>
array(1) {
["geo_locations"]=>
array(1) {
["countries"]=>
string(2) "FR"
}
}
["promoted_object "]=>
array(2) {
["custom_event_type"]=>
string(4) "LEAD"
["pixel_id"]=>
string(16) "2656807074586628"
}
["status"]=>
string(6) "PAUSED"
["access_token"]=>
NULL
}