当前位置: 首页>>代码示例>>PHP>>正文


PHP sms::xml2array方法代码示例

本文整理汇总了PHP中sms::xml2array方法的典型用法代码示例。如果您正苦于以下问题:PHP sms::xml2array方法的具体用法?PHP sms::xml2array怎么用?PHP sms::xml2array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sms的用法示例。


在下文中一共展示了sms::xml2array方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: send_sms

 function send_sms($username, $password, $msisdn, $message, $sender = "COE Alert!", $ScheduledDelivery = "", $force = "premium")
 {
     $url = "http://www.thaibulksms.com/sms_api.php";
     if (extension_loaded('curl')) {
         $data = array('username' => $username, 'password' => $password, 'msisdn' => $msisdn, 'message' => $message, 'sender' => $sender, 'ScheduledDelivery' => $ScheduledDelivery, 'force' => $force);
         $data_string = http_build_query($data);
         $agent = "ThaiBulkSMS API PHP Client";
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_USERAGENT, $agent);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
         $xml_result = curl_exec($ch);
         $code = curl_getinfo($ch);
         curl_close($ch);
         if ($code['http_code'] == 200) {
             if (function_exists('simplexml_load_string')) {
                 $sms = new \SimpleXMLElement($xml_result);
                 $count = count($sms->QUEUE);
                 if ($count > 0) {
                     $count_pass = 0;
                     $count_fail = 0;
                     $used_credit = 0;
                     for ($i = 0; $i < $count; $i++) {
                         if ($sms->QUEUE[$i]->Status) {
                             $count_pass++;
                             $used_credit += $sms->QUEUE[$i]->UsedCredit;
                         } else {
                             $count_fail++;
                         }
                     }
                     if ($count_pass > 0) {
                         $msg_string = "สามารถส่งออกได้จำนวน {$count_pass} หมายเลข, ใช้เครดิตทั้งหมด {$used_credit} เครดิต";
                     }
                     if ($count_fail > 0) {
                         $msg_string = "ไม่สามารถส่งออกได้จำนวน {$count_fail} หมายเลข";
                     }
                 } else {
                     $msg_string = "เกิดข้อผิดพลาดในการทำงาน, (" . $sms->Detail . ")";
                 }
             } else {
                 if (function_exists('xml_parse')) {
                     $xml = sms::xml2array($xml_result);
                     $count = count($xml['SMS']['QUEUE']);
                     if ($count > 0) {
                         $count_pass = 0;
                         $count_fail = 0;
                         $used_credit = 0;
                         for ($i = 0; $i < $count; $i++) {
                             if ($xml['SMS']['QUEUE'][$i]['Status']) {
                                 $count_pass++;
                                 $used_credit += $xml['SMS']['QUEUE'][$i]['UsedCredit'];
                             } else {
                                 $count_fail++;
                             }
                         }
                         if ($count_pass > 0) {
                             $msg_string = "สามารถส่งออกได้จำนวน {$count_pass} หมายเลข, ใช้เครดิตทั้งหมด {$used_credit} เครดิต";
                         }
                         if ($count_fail > 0) {
                             $msg_string = "ไม่สามารถส่งออกได้จำนวน {$count_fail} หมายเลข";
                         }
                     } else {
                         $msg_string = "เกิดข้อผิดพลาดในการทำงาน, (" . $xml['SMS']['Detail'] . ")";
                     }
                 } else {
                     $msg_string = "เกิดข้อผิดพลาดในการทำงาน: <br /> ระบบไม่รองรับฟังก์ชั่น XML";
                 }
             }
         } else {
             //$http_codes = parse_ini_file("http_code.ini");
             //$msg_string = "เกิดข้อผิดพลาดในการทำงาน: <br />" . $code['http_code'] . " " . $http_codes[$code['http_code']];
             $msg_string = "เกิดข้อผิดพลาดในการทำงาน: <br />" . $code['http_code'];
         }
     } else {
         if (function_exists('fsockopen')) {
             $msg_string = $this->sending_fsock($username, $password, $msisdn, $message, $sender, $ScheduledDelivery, $force);
         } else {
             $msg_string = "cURL OR fsockopen is not enabled";
         }
     }
     return $msg_string;
 }
开发者ID:Ranchana,项目名称:Test-Laravel,代码行数:84,代码来源:sms.class.php

示例2: send_sms

 function send_sms($username, $password, $msisdn, $message, $sender = "THAIBULKSMS", $ScheduledDelivery = "", $force = "standard")
 {
     $url = "http://www.thaibulksms.com/sms_api.php";
     //$url = "https://secure.thaibulksms.com/sms_api_test.php";
     if (extension_loaded('curl')) {
         $data = array('username' => $username, 'password' => $password, 'msisdn' => $msisdn, 'message' => $message, 'sender' => $sender, 'ScheduledDelivery' => $ScheduledDelivery, 'force' => $force);
         $data_string = http_build_query($data);
         $agent = "ThaiBulkSMS API PHP Client";
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_USERAGENT, $agent);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
         $xml_result = curl_exec($ch);
         $code = curl_getinfo($ch);
         curl_close($ch);
         echo $xml_result;
         if ($code['http_code'] == 200) {
             if (function_exists('simplexml_load_string')) {
                 $sms = new SimpleXMLElement($xml_result);
                 $count = count($sms->QUEUE);
                 if ($count > 0) {
                     $count_pass = 0;
                     $count_fail = 0;
                     $used_credit = 0;
                     for ($i = 0; $i < $count; $i++) {
                         if ($sms->QUEUE[$i]->Status) {
                             $count_pass++;
                             $used_credit += $sms->QUEUE[$i]->UsedCredit;
                         } else {
                             $count_fail++;
                         }
                     }
                     if ($count_pass > 0) {
                         $msg_string = "Can export the {$count_pass} number, Take all the credit {$used_credit} credit";
                     }
                     if ($count_fail > 0) {
                         $msg_string = "Can not be exported to the {$count_fail} number";
                     }
                 } else {
                     $msg_string = "An error occurred in the workplace, (" . $sms->Detail . ")";
                 }
             } else {
                 if (function_exists('xml_parse')) {
                     $xml = sms::xml2array($xml_result);
                     $count = count($xml['SMS']['QUEUE']);
                     if ($count > 0) {
                         $count_pass = 0;
                         $count_fail = 0;
                         $used_credit = 0;
                         for ($i = 0; $i < $count; $i++) {
                             if ($xml['SMS']['QUEUE'][$i]['Status']) {
                                 $count_pass++;
                                 $used_credit += $xml['SMS']['QUEUE'][$i]['UsedCredit'];
                             } else {
                                 $count_fail++;
                             }
                         }
                         if ($count_pass > 0) {
                             $msg_string = "Can export the {$count_pass} number, Take all the credit {$used_credit} Credit";
                         }
                         if ($count_fail > 0) {
                             $msg_string = "Can not be exported to the {$count_fail} number";
                         }
                     } else {
                         $msg_string = "An error occurred in the workplace., (" . $xml['SMS']['Detail'] . ")";
                     }
                 } else {
                     $msg_string = "An error occurred in the workplace: <br /> The system does not support this function.... XML";
                 }
             }
         } else {
             //$http_codes = parse_ini_file("http_code.ini");
             //$msg_string = "เกิดข้อผิดพลาดในการทำงาน: <br />" . $code['http_code'] . " " . $http_codes[$code['http_code']];
             $msg_string = "An error occurred in the workplace: <br />" . $code['http_code'];
         }
     } else {
         if (function_exists('fsockopen')) {
             $msg_string = $this->sending_fsock($username, $password, $msisdn, $message, $sender, $ScheduledDelivery, $force);
         } else {
             $msg_string = "cURL OR fsockopen is not enabled";
         }
     }
     return $msg_string;
 }
开发者ID:Nkelliny,项目名称:MobileDatingApp,代码行数:86,代码来源:sms.class.php


注:本文中的sms::xml2array方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。