Answer the question
In order to leave comments, you need to log in
How to make HTTP request by url in yii2?
Hello. How to execute a query like this and get a response in YII2:
$url = "https://api.content.market.yandex.ru/v1/category.json?geo_id=213";
$headers = array(
"Host: api.content.market.yandex.ru",
"Accept: */*",
"Authorization: <авторизационный_ключ>"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = curl_exec($ch);
curl_close($ch);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question