以下代码使用POSTMAN完美运行。虽然我尝试使用postman为PHP生成的代码,但它给了我错误。
原始代码:
curl -X POST \
'http://111.93.2.38:8080/gsp/gsp/authenticate?grant_type=token' \
-H 'cache-control: no-cache' \
-H 'gspappid: 64AB7894D61644F3B5CA18B4738C700D' \
-H 'gspappsecret: 70988876GEEEEG4504GB400G92B801E23686' \
PHP代码:
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://111.93.2.38:8080/gsp/gsp/authenticate?grant_type=token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"gspappid: 64AB7894D61644F3B5CA18B4738C700D",
"gspappsecret: 70988876GEEEEG4504GB400G92B801E23686",
"postman-token: ff8278bb-b888-9fd3-6a55-780dafd58aa5"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
请帮帮我。
答案 0 :(得分:0)
您面临什么样的错误,请您分享一下,以便我们为您提供帮助? 如果存在超时错误,您可以尝试更改CURLOPT_TIMEOUT =&gt;的值。 30