[英]Getting 400 Bad Request in cUrl - PHP
我正在運行以下代碼並收到此錯誤:
錯誤的請求
您的瀏覽器發送了此服務器無法理解的請求。
此外,嘗試使用ErrorDocument處理請求時遇到400錯誤請求錯誤。
<?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 vars:
$url = "https://www.example.com/file.php?phone=".urlencode($phone)."&message=".urlencode($message)."";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.