0

こんにちは、PHP で一括 SMS API を使用して一括 SMS を送信しようとしています。私は初心者なので、Google を調べていくつかのスクリプトを見つけましたが、SMS を送信しようとすると、「いいえ」というエラーが表示されます。 DATA RECIEVED" 誰か助けてくれませんか ここは m スクリプトです

<?php

    if (isset($_POST["submit"])) {


         require("includes/config.php");
         require("includes/dbconnect.php");
         require("includes/functions.php");

        $tourdb = DBSUFFIX . $_SESSION["cono"] . "_" . $_SESSION["tourname"];
        mysql_select_db($tourdb);

        $message = substr($_POST["sms"], 0, 160);

        $cond = "";
        if (!empty($_POST["district"])) {
            $district = trim($_POST["district"]);
            $cond .= "AND `district` = '$district'";
        }

        if (!empty($_POST["state"])) {
            $state = trim($_POST["state"]);
            $cond .= "AND `state` = '$state'";
        }

        if (!empty($_POST["for"])) {
            $for = trim($_POST["for"]);
            $cond .= "AND `visitingfor` = '$for'";
        }

        $ccond = "";
        if (!empty($_POST["Airline"])) {
            $air = trim($_POST["Airline"]);
            $ccond .= "AND `airline_code` = '$air'";
        }

        if (!empty($_POST["bjdate"])) {
            $date1 = trim($_POST["bjdate"]);
            $ccond .= "AND `dept_date` = '$date1'";
        }

        if (!empty($_POST["jbdate"])) {
            $date2 = trim($_POST["jbdate"]);
            $ccond .= "AND `dept_date` = '$date2'";
        }

        if (!empty($_POST["siscono"])) {
            $siscono = trim($_POST["siscono"]);
            $cond .= "AND `company` = '$siscono'";
        }

        if (!empty($_POST["batch"])) {
            $batch = $_POST["batch"];
            $ccond .= " AND `batchno` = '$batch' ";
        }

        $hajicond = "";
        if (!empty($_POST["fromhaji"]) && !empty($_POST["tohaji"])) {
            $fromhaji = $_POST["fromhaji"];
            $tohaji = $_POST["tohaji"];
            $hajicond = " AND `hajino` BETWEEN '$fromhaji' AND '$tohaji'";
        }

        $paxcond = "";
        if (!empty($_POST["frompax"]) && !empty($_POST["topax"])) {
            $frompax = $_POST["frompax"];
            $topax = $_POST["topax"];
            $paxcond = " AND `paxid` BETWEEN '$frompax' AND '$topax'";
        }

        $msg = $_POST["sms"];



        $ctr = 0;
        $query = mysql_query("SELECT RIGHT(`mobile`,10) as `mobile`  FROM `pax` WHERE LENGTH(`mobile`) >= 10 AND `paxid` IN (SELECT `paxno` FROM `airline_detail` WHERE paxno IS NOT NULL $ccond) $cond $hajicond $paxcond ") or die(mysql_error());
            while ($pax = mysql_fetch_array($query)){
                $ctr++;
                $to.= "$pax[mobile],";
             }  

    $to.= "8652372200";

    $user = "****";
    $password = "t*****"; 
    $mobilenumbers = "$to";
    $message = "$msg";
    $senderid = "****";
    $url = "http://tran.mobilogi.com/api/httpapi.php";
    $message = urlencode($message);
    $ch = curl_init();
    echo "$user";
    if (!$ch) {
        die("Couldn't initialize a cURL handle");
    }
    $ret = curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "username=$user&password=$password&to=$mobilenumbers&sender=$senderid&message=$message");

    $ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);



    $curlresponse = curl_exec($ch);
    if (curl_errno($ch))
        echo 'curl error : ' . curl_error($ch);

    if (empty($ret)) {

        die(curl_error($ch));
        curl_close($ch); 
    } else {
        $info = curl_getinfo($ch);
        curl_close($ch);

        echo $curlresponse;
        }



    }
    ?>
4

2 に答える 2

1

SMS を直接送信できる PHP または JavaScript の機能はありません。SMS は基本的にShort Message Peer-to-Peer (SMPP) プロトコルに基づいているため、プログラムで SMS を直接送信する方法はありません。はい、php から http リクエストを作成できる smsgateway または既存の API を使用できます。VAS プロバイダーのような sms サービス プロバイダーはたくさんあり、kannel のような無料でオープン ソースの smsgateway もたくさんあり、sms の送受信に使用したり、独自のゲートウェイを構成したりすることもできます。

メッセージを送信するにはサードパーティが必要であり、メッセージを送信するために何かを支払う必要もあります. 私は自分で試したことはありませんが、HTTP を介した SMS の送信に関するこのチュートリアルは良い方法のようです。それはあなたができるようになります

Use PHP and the HTTP protocol to send text-messages from your website through an SMS gateway.
于 2013-03-02T07:20:05.123 に答える