doudan4834 2016-06-29 06:47
浏览 51

如何在laravel 4.2中创建用于发送SMS的XML对象?

I am trying to send sms to mobile numbers of users in my project. I need to send sms by using xml format given by sms provider and it is shown below.

<MESSAGE>     
    <AUTHKEY>Authentication Key </AUTHKEY>     
    <SENDER>SenderID</SENDER>     
    <ROUTE>Template</ROUTE>     
    <CAMPAIGN>XML API</CAMPAIGN>     
    <SMS TEXT="message1" >         
        <ADDRESS TO="number1"></ADDRESS>         
        <ADDRESS TO="number2"></ADDRESS>     
    </SMS>
</MESSAGE>

My program forsending SMS is given below

public function sendUserSms()
    {
        $usernos = array();
        $users = User::all();
        foreach ($users as $key => $user) {
            $xmlpno = new SimpleXMLElement("<ADDRESS></ADDRESS>");
            $xmlpno->addAttribute('TO', $user->mobile);
            $usernos[] = (string) $xmlpno;
        }
    }
$xmlmsg = '<MESSAGE>     
                    <AUTHKEY>Authentication Key </AUTHKEY>     
                    <SENDER>SenderID</SENDER>     
                    <ROUTE>Template</ROUTE>     
                    <CAMPAIGN>XML API</CAMPAIGN>     
                    <SMS TEXT="hello_test_message" >'.implode($usernos).'    
                    </SMS>
                </MESSAGE>';
var_dump($xmlmsg);

It shows nothing. Anybody know what is the problem? Can anyone help?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 路易威登官网 里边的参数逆向
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
    • ¥50 需求一个up主付费课程
    • ¥20 模型在y分布之外的数据上预测能力不好如何解决
    • ¥15 processing提取音乐节奏