gpt4 book ai didi

php - 在 cUrl 中获取 400 错误请求 - PHP

转载 作者:可可西里 更新时间:2023-11-01 00:18:52 27 4
gpt4 key购买 nike

我正在运行以下代码并收到此错误:

Bad Request

Your browser sent a request that this server could not understand.

Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request.

    <?php
$phone = "1236547895";
$message = 'Dear '.$firstname.' '.$lastname.',

Your invoice (#'.$invoiceid.') is successfully paid on '.$datepaid.' at Hostomy. Thank you for choosing us.

Regards,
Hostomy
';
$url = "https://www.example.com/file.php?phone=".$phone."&message=".$message."";
$ch = curl_init();
$timeout = 10;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
?>

最佳答案

尝试 urlencode消息和 $phone 变量:
$url = "https://www.example.com/file.php?phone=".urlencode($phone)."&message=".urlencode($message)."";

关于php - 在 cUrl 中获取 400 错误请求 - PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42257105/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com