php - 你好,我用php curl做了一个研究,响应没有我想要的响应。问题出在哪里?
问题描述
我用 Php curl 进行了一项研究,响应没有按我的意愿响应。问题出在哪里,请帮忙。
回复:
Array ( [timestamp] => 1611484830616 [status] => 415 [error] => Unsupported Media Type [exception] => org.springframework.web.HttpMediaTypeNotSupportedException [message] => Unsupported Media Type [path] => /squat/getSquatMarketingProduct )
php代码:
$post = array(
'clientKey' => 'AC491770-B16A-4273-9CE7-CA790F63365E',
'clientVersion' => '13.0.1',
'language' => 'tr',
'operatingSystem' => 'android'
);
$headers = array(
'Content-Type'=> 'application/json',
'Host' => 'm.vodafone.com.tr',
'Connection' => 'Keep-Alive',
'Accept-Encoding' => 'gzip',
'User-Agent' => 'okhttp/3.14.1'
);
$cs = curl_init();
curl_setopt($cs, CURLOPT_URL,"https://example.com/api?sid=".$token);
curl_setopt($cs, CURLOPT_POST, TRUE);
curl_setopt($cs, CURLOPT_POSTFIELDS, $post);
curl_setopt($cs, CURLOPT_HTTPHEADER, $headers);
curl_setopt($cs, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($cs);
$jsons = json_decode($output, true);
print_r($jsons);
curl_close ($cs);
解决方案
推荐阅读
- java - 是否可以使用 selenium 从 chrome 浏览器读取下载的文件
- php - 如何使用 PHP 获取 excel 文件中的前一列索引?
- azure-api-management - jwt 验证 azure api 管理
- mysql-workbench - 想在 3 个月期间过滤几个数据 mysql
- r - 为什么 Unicode 会从 excel 文件转换为 r 数据框
- java - 在 intellij 中使用 java 连接到数据库(postgres)
- firebase - Firebase 向特定人员提供身份验证
- django - Django UpdateForm DateInput 小部件不显示日期
- android - 具有轮廓但透明背景的 TextInputLayout
- java - jdbc 使用自动增量字段将数据插入数据库