Я использую библиотеку PHP Requests для http запроса:
$url = Qrcode_url;
$data = array(
'amount'=> 12,
'currency'=>'USD',
'reference'=>'123456765432',
'ipn_url'=>'http://website.com/ipn'
);
// $token
$headers = array("Authorization" => "Bearer 123456", 'Content-Type' => 'application/json');
$options = $data;
$request = Requests::post($url, $headers, array());
echo '<pre>';
print_r($request);
Это вывод на моем экране:
Requests_Response Object
(
[body] =>
HTTP Status 415 -
type Status report
message
description The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.
Apache Tomcat/7.0.84
[raw] => HTTP/1.1 415 Unsupported Media Type
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 1048
Date: Fri, 30 Nov 2018 11:07:27 GMT
Via: 1.1 google
Alt-Svc: clear
Connection: close
HTTP Status 415 -
type Status report
message
description The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.
Apache Tomcat/7.0.84
[headers] => Requests_Response_Headers Object
(
[data:protected] => Array
(
[server] => Array
(
[0] => Apache-Coyote/1.1
)
[content-type] => Array
(
[0] => text/html;charset=utf-8
)
[content-language] => Array
(
[0] => en
)
[content-length] => Array
(
[0] => 1048
)
[date] => Array
(
[0] => Fri, 30 Nov 2018 11:07:27 GMT
)
[via] => Array
(
[0] => 1.1 google
)
[alt-svc] => Array
(
[0] => clear
)
)
)
[status_code] => 415
[protocol_version] => 1.1
[success] =>
[redirects] => 0
[url] => https://api.ttpay.com/v1.3/transactions/qrcode
[history] => Array
(
)
[cookies] => Requests_Cookie_Jar Object
(
[cookies:protected] => Array
(
)
)
)
В верхней части отображается ошибка, вы видите, я изменилContent-Type
заголовок к application/json
в моем запросе, но почему я получаю верхнюю ошибку?
токен верен, и, пожалуйста, обратите внимание, что заголовок запроса в ошибке печати по-прежнему равен text/html
,как я могу решить мою проблему?