-1

我需要为我们大学创建一个批量短信服务应用程序,以下文件是发送短信的表格。

索引.php

<body>
<?php
//Code using curl

//Change your configurations here.
//---------------------------------
$username="XYZ";
$api_password="4dlfed5scaweod1";
$sender="test";
$domain="your_domain";
$priority="1";// 1-Normal,2-Priority,3-Marketing
$method="POST";
//---------------------------------

if(isset($_REQUEST['send']))
    {

        $mobile=$_REQUEST['mobile'];

        $message=$_REQUEST['message'];

        $username=urlencode($username);
        $api_password=urlencode($api_password);
        $sender=urlencode($sender);
        $message=urlencode($message);

        $parameters="username=$username&api_password=$api_password&sender=$sender&to=$mobile&message=$message&priority=$priority";

        $url="http://bulksms.gateway4sms.com/pushsms.php";

        $ch = curl_init($url);

        if($method=="POST")
        {
            curl_setopt($ch, CURLOPT_POST,1);
            curl_setopt($ch, CURLOPT_POSTFIELDS,$parameters);
        }
        else
        {
            $get_url=$url."?".$parameters;

            curl_setopt($ch, CURLOPT_POST,0);
            curl_setopt($ch, CURLOPT_URL, $get_url);
        }

        curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); 
        curl_setopt($ch, CURLOPT_HEADER,0);  // DO NOT RETURN HTTP HEADERS 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);  // RETURN THE CONTENTS OF THE CALL
        $return_val = curl_exec($ch);


        if($return_val=="")
        echo "Process Failed, Please check domain, username and password.";
        else
            echo "$return_val";

        }
?>
<article>
<h1>SMS APPLICATION</h1>
<form name="f1" method="post">
    <ul>
        <li>
            <label for="name"> Name:</label>
            <input type="text" size="40" id="name" />
        </li>

        <li>
            <label for="year">To the Students of:</label>
            <select id="year">
                <option>1st year</option>
                <option>2nd year</option>
                <option>3rd year</option>
                <option>4th year</option>
            </select>
        </li>

        <li>
            <label for="message">Message:</label>
            <textarea cols="50" rows="5" id="message" name="message"></textarea>
        </li>
    </ul>


     <p>
            <button type="submit" class="action" name="send">Send Message</button>
            <button type="reset" class="right">Reset</button>
        </p>
    </form>
    </article>
    <footer>
    </footer>

用户应该能够从列表中发送给学生组。电话号码存储在名为“电话簿”的表中的数据库中

电话簿表

id  NAME          number       year
1   subh       90199492070     1st year
2   saefh      90199493050     2nd year
3   sawd       90199390450     1st year
4   suwd       90199543450     4th year 

我如何检索数字以从数据库中发送人员

4

1 回答 1

1

好像没试过。我可以给你一些想法。

  • 查询您的数据库并从电话簿表中检索结果。(假设查询将SELECT name,number FROM phonebook
  • 在数组中获取这些结果 [姓名和手机号码]。
  • 利用循环说一个for循环并在其中添加你的cURL代码..这样

    for($i=0;$i<count($results);$i++) { //.... your cURL code }

于 2013-10-20T05:39:14.153 回答