My code, without any libraries, gets from Binance in response 404 Not Found

$ API_KEY= "***";
$ ch= curl_init ();
    $ ch,
    Array (
        Curlopt_url= >
        Curlopt_returntransfer= >
        Curlopt_Header= >
        Curlopt_httpheader= >
 Array ("Content-Type: Application /X-WWW-FORM-URLENCODED", "X-MBX-APIKEY:" $ API_KEY),
        Curlopt_post= >
        Curlopt_postfields= >
 "Symbol= TRXBTC",
$ result= curl_exec ($ CH);
$ result= json_decode ($ result);
Echo '<
Pre >
Print_R ($ result);
Echo '<
Pre >

if I send without a post, i.e, deleting these two lines.

curlopt_post= >
Curlopt_postfields= >
 "Symbol= TRXBTC",

sends a long array with all prices

Tell me what I do wrong?

Empty data means an incorrect request, most likely, try curlopt_postfields by an array, not a string, Content-Type Curl may install

Jean-Claude2021-05-09 19:15:18

If you remove $ result= json_decode ($ result); That will be released no empty data A 404 Not Found. The API seems to be written through the string, but I tried the array and the same effect, also 404 not Found

Леха2021-05-09 19:27:00

Actually, CURL_EXEC () can return false or an empty string "", where is your check on this before Parsing JSON?

Jean-Claude2021-05-09 19:30:50

If you remove, if you do not remove, a bad story of you, I can't guess, can you tritely need curlopt_ssl_verifypeer

Jean-Claude2021-05-09 19:33:05