Php 为什么curl返回空字符串
我正在尝试通过php,curl登录到一个网页。问题是curl返回一个空字符串,我不明白为什么 我发送的参数是正确的,我已经用Burpusuite检查过了 来自CURLOPT_STDERR的日志 我的代码:Php 为什么curl返回空字符串,php,curl,Php,Curl,我正在尝试通过php,curl登录到一个网页。问题是curl返回一个空字符串,我不明白为什么 我发送的参数是正确的,我已经用Burpusuite检查过了 来自CURLOPT_STDERR的日志 我的代码: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://gameforge.com/api/v1/auth/thin/sessions"); curl_setopt($ch, CURLOPT_POSTFIELDS,
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://gameforge.com/api/v1/auth/thin/sessions");
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"identity":"'.$mail.'","password":"'.$password.'","locale":"es_ES",
"gfLang":"es","platformGameId":"07b3e4d5-f37e-440b-9aa5-b249121a6bfa","gameEnvironmentId":"5c71b04b-a0c3-4792-be4f-81f97c25d8a8","autoGameAccountCreation":false}');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
print_r(curl_getinfo($ch));
curl_close($ch);
var_dump($res);
die();
打印结果(curl_getinfo($ch));和var_dump($res)
阅读你的协议。您正在使用内容类型application/x-www-form-urlencoded,但正在发送application/json。
Array
(
[url] => https://gameforge.com/api/v1/auth/thin/sessions
[content_type] =>
[http_code] => 409
[header_size] => 666
[request_size] => 146
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.102569
[namelookup_time] => 0.000876
[connect_time] => 0.005851
[pretransfer_time] => 0.023868
[size_upload] => 253
[size_download] => 0
[speed_download] => 0
[speed_upload] => 2480
[download_content_length] => 0
[upload_content_length] => 253
[starttransfer_time] => 0.023873
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => 121.23.13.2
[certinfo] => Array
(
)
[primary_port] => 443
[local_ip] => 31.23.93.11
[local_port] => 39462
[http_version] => 3
[protocol] => 2
[ssl_verifyresult] => 0
[scheme] => HTTPS
[appconnect_time_us] => 23672
[connect_time_us] => 5851
[namelookup_time_us] => 876
[pretransfer_time_us] => 23868
[redirect_time_us] => 0
[starttransfer_time_us] => 23873
[total_time_us] => 102569
)
string(0) ""