PHP-Send SMS

Source: Internet
Author: User
Tags sendmsg

1. Purchase Service

I purchased the API service that was promoted in Baidu. Buy as required, then get your own apikey.

2. Modify the provided code to integrate into the project:

<?php    /**     * * *      Send SMS * * * *    /class Phonemsg{public $ak = ' Apikey: *************** ';        Public Function sendphonemsg ($phonenumber, $sendmsg) {            $ch = Curl_init ();            $url = ' http://apis.baidu.com/kingtto_media/106sms/106sms?mobile= '. $phonenumber. ' &content= '. $sendmsg;            $header = Array ($ak);            curl_setopt ($ch, Curlopt_httpheader  , $header);            curl_setopt ($ch, Curlopt_returntransfer, 1);            curl_setopt ($ch, Curlopt_url, $url);            $res = curl_exec ($ch);            return $res;        }    }? >

<?php    /**     * *      send mobile phone verification short Note *      * *    /session_start ();        Generate random Code $rand = substr ($randStr, 0,6);    $randnum = Array ();    for ($i =0; $i <5; $i + +) {        $randnum []=rand (0,9);//     }    $uniqid = implode ($randnum);        $_session[' validnum '] = $uniqid;        $validNum = UrlEncode (' Instant print ' Your verification code is: '. $uniqid. '. If you do not operate, please ignore this message ');        Require_once "phoneMsg.class.php";        $send = new Phonemsg ();        There is a return value that can get the return information    $res = $send->sendphonemsg ($_post[' PhoneNumber '), $validNum); >

PHP-Send SMS

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.