foreach($data as $key => $value) {
foreach($value['items']['product'] as $v) {
$response[] = array(
"Products" => array(
"product" => $v
)
);
}
}
foreach($data as $key => $value) {
foreach($value['items']['productPrice'] as $v) {
$response[] = array(
"Products" => array(
"productPrice" => $v
)
);
}
}
Array
(
[0] => Array
(
[Products] => Array
(
[product] => Test1
)
)
[1] => Array
(
[Products] => Array
(
[product] => Test2
)
)
[2] => Array
(
[Products] => Array
(
[productPrice] => 123
)
)
[3] => Array
(
[Products] => Array
(
[productPrice] => 312312
)
)
)
$url = 'https://api.shate-m.kz/api/v1/auth/loginbyapikey';
$headers = array(
"accept: text/plain",
"Content-Type: application/x-www-form-urlencoded",
);
$apikey = array(
"ApiKey" => "apikey"
);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_HTTPHEADER, $headers,
CURLOPT_POSTFIELDS, json_encode($apikey, JSON_UNESCAPED_UNICODE),
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_SSL_VERIFYHOST => FALSE,
CURLOPT_POST => 1,
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url,
));
if(!$result = curl_exec($curl))
{
$result = curl_error($curl);
}
curl_close($curl);
$result = json_decode($result, true);
echo '<pre>';
print_r($result);
echo '<pre>';
Array
(
[code] => RequestModelValidationError
[description] => Ошибка валидации параметров запроса
[traceId] => 00-02b31948e1eb8545c7d59980fee25463-975a0dc5ba76cf64-00
[messages] => Array
(
[0] => ApiKey: The ApiKey field is required.
)
)