Php text message interface example code (getting started)

Source: Internet
Author: User
Php text message interface example code (getting started)
This article shares a piece of php text message interface code, which is very simple for beginners to refer to. if the website uses the text message interface function, this example can be used for reference.

Php text message interface file:

     $ Uid, // User account 'pwd' => strtolower (md5 ($ pwd), // MD5 32-bit password 'mobile' => $ mobile, // number 'content' => $ content, // content 'time' => $ time, // timed sending of 'mid '=> $ mid // subextension number ); $ re = postSMS ($ http, $ data); // submit if (trim ($ re) = '000000') {return "sent successfully! ";} Else {return" failed to send! Status :". $ re ;}} function postSMS ($ url, $ data = '') {$ row = parse_url ($ url); $ host = $ row ['host']; $ port = $ row ['port']? $ Row ['port']: 80; $ file = $ row ['path']; while (list ($ k, $ v) = each ($ data )) {$ post. = rawurlencode ($ k ). "= ". rawurlencode ($ v ). "&"; // URL conversion standard code} $ post = substr ($ post, 0,-1); $ len = strlen ($ post ); $ fp = @ fsockopen ($ host, $ port, $ errno, $ errstr, 10); if (! $ Fp) {return "$ errstr ($ errno) \ n";} else {$ receive = ''; $ out = "POST $ file HTTP/1.1 \ r \ n"; $ out. = "Host: $ host \ r \ n"; $ out. = "Content-type: application/x-www-form-urlencoded \ r \ n"; $ out. = "Connection: Close \ r \ n"; $ out. = "Content-Length: $ len \ r \ n"; $ out. = $ post; fwrite ($ fp, $ out); while (! Feof ($ fp) {$ receive. = fgets ($ fp, 128);} fclose ($ fp); $ receive = explode ("\ r \ n", $ receive ); unset ($ receive [0]); return implode ("", $ receive) ;}}?>
Guess you like: php SMS sending function php SMS interface function instance code

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.