Php sms api在本地计算机中不工作,但在主机服务器中工作

Php sms api在本地计算机中不工作,但在主机服务器中工作,php,mysql,api,sms,Php,Mysql,Api,Sms,下面的php代码在web服务器上运行良好(即sms服务器 位于)但在使用xampp或wamp的本地机器上工作不正常 实际服务器位于godaddy中 我错过了什么 代码从表中检索连接详细信息,该表包括: 用户名、密码、msisdn和发件人。当消息最终发送时, 该消息已标记,因此不会再次发送 <?php $id = 0; $con=mysqli_connect("localhost","root","","afrcan_wp"); // Check connection if (mysql

下面的php代码在web服务器上运行良好(即sms服务器 位于)但在使用
xampp
wamp
的本地机器上工作不正常

实际服务器位于godaddy中

我错过了什么

代码从表中检索连接详细信息,该表包括: 用户名、密码、msisdn和发件人。当消息最终发送时, 该消息已标记,因此不会再次发送

<?php

$id = 0;

$con=mysqli_connect("localhost","root","","afrcan_wp");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$sql="SELECT id,message,username,password,MSISDN,sender,messagestatus FROM outgoingsms where messagestatus = 'not sent' LIMIT 1";

if ($result=mysqli_query($con,$sql))
  {
  // Fetch one and one row
  while ($row=mysqli_fetch_row($result))
    {

    $id=$row[0];    

    $text1=$row[1];

    $username=$row[2];

    $password=$row[3];

    $to=$row[4];

    $sender=$row[5];

    $messagestatus=$row[6];

 //$conn1=mysqli_connect("localhost","afrcan_wp","Sirhenry888","afrcan_wp");
$conn1 = new mysqli("localhost","root","","african_wp");
// Check connection
if ($conn1->connect_error) {
    die("Connection failed: " . $conn1->connect_error);
} 

$sql = "UPDATE outgoingsms SET messagestatus='sent' WHERE id=$id";

if ($conn1->query($sql) === TRUE) {
    echo "Record updated successfully";
} else {
    echo "Error updating record: " . $conn1->error;
}


$text = trim($text1);

$postUrl = "https://www.connectmedia.co.ke/user-board/?api";

$action="send";

$post = [
'action' => "$action",
'to' => array($to),
'username' => "$username",
'password' => "$password",
'sender' => "$sender",
'message' => urlencode("$text"),
];
$ch = curl_init($postUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
$response = curl_exec($ch);
curl_close($ch);
echo "$response";

    //send messages
    }
  // Free result set
  mysqli_free_result($result);

 $conn1->close();

}

mysqli_close($con);

?>

这是代码的问题吗?互联网连接


非常感谢您提供的任何帮助

如果这在web服务器上有效,但在本地主机上无效,那么可能是因为CURL存在防火墙问题。默认情况下,CURL使用端口1080。检查该端口在本地主机上是否为opn,或者尝试通过执行以下操作更改该端口

curl_setopt ($ch, CURLOPT_PORT , 8089);