如何在成功插入数据后使用 API 向号码发送短信并将其重定向到我的网站页面
How to send sms to a number using API when data is successfully inserted and also redirect it to my website pages
$qins="INSERT INTO citizen_request(name,mobile,description,id,status,file) VALUES('$name','$mobile','$description','$id','$status','$new_image_name')";
mysqli_query($con,$qins);
if(mysqli_affected_rows($con)>0)
{
move_uploaded_file($image_temp,"upload/request/".$new_image_name);
copy( __DIR__ . "/upload/request/".$new_image_name, __DIR__ . "/user/upload/request/".$new_image_name );
$ch = curl_init('http://some.com/api/mt/SendSMS?urldata');
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
<?php
}
我想做的是在成功进入时发送短信并将其重定向到我的页面 request-entry.php?success=yess ,当使用 curl 时返回“Bad Request
HTTP 错误 400。请求格式错误。"
当我使用重定向
<script language='javascript'>
location.href="http://some.com/api/mt/SendSMS?urldata";
</script>
消息运行成功,但它会转到短信提供商页面。
当像这样使用两个链接时
<script language='javascript'>
location.href="http://some.com/api/mt/SendSMS?urldata1";
location.href="request-entry.php?success=yess";
</script>
它正在重定向到请求-entry.php 页面,但短信没有发送
$message = rawurlencode('This is your message');
// Prepare data for POST request
$data = "futherurldata";
// Send the GET request with cURL
$ch = curl_init('http://login.xyz.com/api/mt/SendSMS?' . $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// Process your response here
echo $response;
这应该有效
$qins="INSERT INTO citizen_request(name,mobile,description,id,status,file) VALUES('$name','$mobile','$description','$id','$status','$new_image_name')";
mysqli_query($con,$qins);
if(mysqli_affected_rows($con)>0)
{
move_uploaded_file($image_temp,"upload/request/".$new_image_name);
copy( __DIR__ . "/upload/request/".$new_image_name, __DIR__ . "/user/upload/request/".$new_image_name );
$ch = curl_init('http://some.com/api/mt/SendSMS?urldata');
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
<?php
}
我想做的是在成功进入时发送短信并将其重定向到我的页面 request-entry.php?success=yess ,当使用 curl 时返回“Bad Request
HTTP 错误 400。请求格式错误。" 当我使用重定向
<script language='javascript'>
location.href="http://some.com/api/mt/SendSMS?urldata";
</script>
消息运行成功,但它会转到短信提供商页面。 当像这样使用两个链接时
<script language='javascript'>
location.href="http://some.com/api/mt/SendSMS?urldata1";
location.href="request-entry.php?success=yess";
</script>
它正在重定向到请求-entry.php 页面,但短信没有发送
$message = rawurlencode('This is your message');
// Prepare data for POST request
$data = "futherurldata";
// Send the GET request with cURL
$ch = curl_init('http://login.xyz.com/api/mt/SendSMS?' . $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// Process your response here
echo $response;
这应该有效