php_network_getaddresses:getaddrinfo失败:名称或服务未知(0)

时间:2019-04-24 08:09:02

标签: php sms-gateway

这是我第一次尝试集成sms网关,但是我陷入其中的困境很深,不知道如何克服此问题。请帮帮我,

这是我的php代码:

<?php

$user = "parshwawebsolutions";
$password = "12646";
$senderid = "PARSHWA";
$smsurl = "http://sms.parshwawebsolutions.com/ComposeSMS.aspx?";

function httpRequest($url){
    $pattern = "/http...([0-9a-zA-Z-.]*).([0-9]*).(.*)/";
    preg_match($pattern,$url,$args);
    $in = "";
    $fp = fsockopen($args[1],80, $errno, $errstr, 30);
    if (!$fp) {
       return("$errstr ($errno)");
    } else {
  $args[3] = "C".$args[3];
        $out = "GET /$args[3] HTTP/1.1\r\n";
        $out .= "Host: $args[1]:$args[2]\r\n";
        $out .= "User-agent: PARSHWA WEB SOLUTIONS\r\n";
        $out .= "Accept: */*\r\n";
        $out .= "Connection: Close\r\n\r\n";

        fwrite($fp, $out);
        while (!feof($fp)) {
           $in.=fgets($fp, 128);
        }
    }
    fclose($fp);
    return($in);
}



function SMSSend($phone, $msg, $debug=false){
      global $user,$password,$senderid,$smsurl;

      $url = 'username='.$user;
      $url.= '&password='.$password;
      $url.= '&sender='.$senderid;
      $url.= '&to='.urlencode($phone);
      $url.= '&message='.urlencode($msg);
      $url.= '&priority=1';
      $url.= '&dnd=1';
      $url.= '&unicode=0';


      $urltouse =  $smsurl.$url;
      if ($debug) { echo "Request: <br>$urltouse<br><br>"; }

      //Open the URL to send the message
      $response = httpRequest($urltouse);
      if ($debug) {
           echo "Response: <br><pre>".
           str_replace(array("<",">"),array("&lt;","&gt;"),$response).
           "</pre><br>"; }

      return($response);
}

$phonenum = $_POST['recipient'];
$message = $_POST['message'];
$debug = true;

SMSSend($phonenum,$message,$debug);

?>

我收到这样的错误:

响应:

php_network_getaddresses:getaddrinfo失败:名称或服务未知(0)

先谢谢了。

0 个答案:

没有答案