首页 > 解决方案 > 你好,我用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);

标签: phpcurlpython-requestsrequest

解决方案


推荐阅读