отправляю JSON массив с другого сайта с помощью cUrl
Код: Выделить всё
$data = $_POST;
$data = json_encode($data);
$ch = curl_init('https://site.ku/zakaz/create');
curl_setopt($ch, CURLOPT_POST, true); //переключаем запрос в POST
curl_setopt($ch, CURLOPT_POSTFIELDS,$data); //Это POST данные
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //Отключим проверку сертификата https
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //из той же оперы
curl_exec($ch);
curl_close($ch);
Код: Выделить всё
public function actionCreate()
{
if (Yii::$app->request->post()) {
$model = \yii\helpers\Json::decode(Yii::$app->request->post());
return $this->redirect(['index']);
}
return $this->redirect(['index']);
}
Завардампил Yii::$app->request->post() получается вот такая лабуда JSON внутри array
Код: Выделить всё
array(1) { ["{"name_fio":"sfgsgf","count":"34","telephone":"3365","zipcode":"33","region":"fgdsf","city":"ddfsdf","street":"dsfgsdf","house":"55","apartment":"55","ref":"","lend":"2"}"]=> string(0) "" }