Я решил эту проблему, пожалуйста, проверьте этот код ниже
<?php
// Your code here!
$data = "&userId=";
$data_string = $data;
$url = 'http://apptellect.cloudapp.net/binance/api/v1/get_user_assets/';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo $result = curl_exec($ch);
echo '<hr>';
curl_close($ch);
// This will remove unwanted characters.
// Check http://www.php.net/chr for details
for ($i = 0; $i <= 31; ++$i) {
$result = str_replace(chr($i), "", $result);
}
$result = str_replace(chr(127), "", $result);
// This is the most common part
// Some file begins with 'efbbbf' to mark the beginning of the file. (binary level)
// here we detect it and we remove it, basically it's the first 3 characters
if (0 === strpos(bin2hex($result), 'efbbbf')) {
$result = substr($result, 3);
}
$json_result = json_decode($result, true);
echo json_last_error_msg();
echo '<hr>';
print_r($json_result);
?>
Я уверен, что он работает правильно, пожалуйста, проверьте
Curl отправил ответ json. Это отображение правильного json, но у него есть нежелательные символы,Мы удалили ненужный символ двоичного уровня. Затем перейдем к функции json_decode
Счастливое программирование
Спасибо, AS