M
M
Monitorkin2017-01-25 13:49:38
Yii
Monitorkin, 2017-01-25 13:49:38

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

1 answer(s)
D
Dmitry, 2017-01-25
@Monitorkin

Good afternoon.
Everything is much easier.
The framework-e has a built-in tool for working with cUrl ..

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question