Sample code for PHP SMS interface (Getting started)

Source: Internet
Author: User
This article shares a PHP SMS interface code, very simple, for beginners to refer to friends, if the site useful to the text messaging interface function, this example can be used for reference.

PHP SMS Interface file:

     $uid,//user account ' pwd ' =>strtolower (MD5 ($PWD)),//md5-bit 32 password ' mobile ' + $mobile,//number ' content ' = + $content,// Content ' time ' = $time,//timed to send ' mid ' + $mid//Sub-extension number);   $re = Postsms ($http, $data); Post method Submit if (trim ($re) = = ' + ') {return ' sent successfully! ';} else {return ' send failed! 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)." & "; Go to URL 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\r\n";    $out. = $post;  Fwrite ($fp, $out); while (!feof ($fp)) {$receivE. = Fgets ($fp, 128);  } fclose ($FP);  $receive = Explode ("\r\n\r\n", $receive);  unset ($receive [0]); Return implode ("", $receive);}}? >
Guess you like: PHP Short message sending function example code of PHP SMS interface function
  • 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.