A
A
Alexey Tipa2021-05-20 14:09:42
PHP
Alexey Tipa, 2021-05-20 14:09:42

Why is $data not coming?

The problem is that when accessing the api (I hid the URL with an asterisk), $postdata does not come if I make a request from php.
Tell me what's wrong, please?

$data = array("category" => 2);

$postdata = http_build_query($data);
  
$options = array(
    'http' => array(
        'header' => 'Content-type: application/json; charset=utf-8',
        'method' => 'GET',
        'content' => $postdata
    )
);
  
$stream = stream_context_create($options);

$api_url = "****";

$result = file_get_contents($api_url, false, $stream);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question