PHP SMS Delivery service youe SMS Enterprise service

Source: Internet
Author: User

     /** General SMS Platform HTTP interface post method send SMS Instance * Return String * This method is typically called*/function Postsendmessage ($msgContents, $phoneListStr) {//echo $phoneListStr. ' <br/> ';$ShortMSGUid ='123456';//SMS Service user name$SHORTMSGPWD ='123456';//SMS Service Password$ShortMSGSignature ='"signature Example"';//SMS Service Signature//$CustomerServicePhoneList =array (' 185******** ', ' 185******** '); //$phoneListStr = implode ('; ', $CustomerServicePhoneList);$url="http://www.smsadmin.cn/smsmarketing/wwwroot/api/post_send/";//Universal SMS Platform Interface address$uid = $ShortMSGUid;//the user ID you registered on the Universal SMS Platform//$uid =mb_convert_encoding ($uid, ' GB2312 ', ' UTF-8 ');//transcoding into GB2312 when content is UTF-8$ShortMSGSignature = mb_convert_encoding ($ShortMSGSignature,'GB2312','UTF-8');//when you have Chinese characters, add$msgContents = mb_convert_encoding ($msgContents,'GB2312','UTF-8'); $pwd= $SHORTMSGPWD;//User Password$msg = $msgContents. $ShortMSGSignature;//" Universal SMS Platform"; //to send the text message content, must be signed, signature format: "Signature content"//$msg =mb_convert_encoding ($msg, ' GB2312 ', ' UTF-8 ');//transcoding into GB2312 when content is UTF-8$mobile = $PHONELISTSTR;//to receive SMS mobile phone number, multiple mobile phone number in English semicolon (;) interval, up to 1000 mobile phone number. $params=Array ("UID"=$uid,"pwd"=$pwd,"Mobile"=$mobile,"msg"=$msg,"Dtime"="",//is empty, the message is sent immediately, the write time is timed to send SMS time, time format: 0000-00-00 00:00:00            "LinkId"=""   //empty, indicating no serial number; write serial number, get status report and SMS reply return serial number, serial number format requirement: Maximum length cannot exceed 32 digits, numeric, alphabetic, alphanumeric combination of strings        ); $results= $ This->posttohosts ($url, $params); /*submit successful return value format: 0 sent successfully!*/    }        /** * Submit via Post*/function posttohosts ($url, $data) {$url=Parse_url ($url); if(! $url)return "couldn ' t parse URL"; if(!isset ($url ['Port']) {$url ['Port'] =""; } if(!isset ($url ['Query']) {$url ['Query'] =""; } $encoded="";  while(List ($k, $v) =Each ($data)) {$encoded.= ($encoded?"&":""); $encoded.= Rawurlencode ($k)."=". Rawurlencode ($v); }        //echo $encoded;$fp = Fsockopen ($url ['Host'], $url ['Port'] ? $url ['Port'] : the); if(! $fp)return "Failed to open socket to $url [host]"; Fputs ($fp, sprintf ("POST%s%s%s http/1.0\n", $url ['Path'], $url ['Query'] ?"?":"", $url ['Query'])); Fputs ($FP,"Host: $url [host]\n"); Fputs ($FP,"content-type:application/x-www-form-urlencoded\n"); Fputs ($FP,"content-length:". Strlen ($encoded)."\ n"); Fputs ($FP,"connection:close\n\n"); Fputs ($FP,"$encoded \ n"); $line= Fgets ($FP,1024x768); if(!preg_match ("{^http/1\: $}", $line))return; $results=""; $inheader=1;  while(!feof ($FP)) {$line= Fgets ($FP,1024x768); if($inheader && ($line = ="\ n"|| $line = ="\ r \ n") {$inheader=0; }elseif (!$inheader) {$results.=$line;        }} fclose ($FP); return$results; }

PHP SMS Delivery service youe SMS Enterprise service

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.