2 回答

TA貢獻1831條經驗 獲得超10個贊
也許問題是您在數組中發送 post 字段值而不是 URL 編碼,使用http_build_query或 json_encode 并檢查。
檢查下面的代碼。
if(!empty($_POST)){
echo "<pre>";
print_r($_POST);
echo "</pre>";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
$data = $_POST;
/*** you are direct sending the array value
use http_build_query
or
$data_string = json_encode($data);
***/
$data_string = http_build_query($data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string );
$out = curl_exec($ch);
$inf = curl_getinfo($ch);
curl_close($ch);
echo "<pre>";
print_r($out);
print_r($inf);
echo "</pre>";
exit;
}
- 2 回答
- 0 關注
- 161 瀏覽
添加回答
舉報