PHP Call Cloud Mesh Interface implementation of the case of sending text messages

Source: Internet
Author: User
the implementation method of sending text messages by PHP in the Cloud Slice network interface

Cloud Mesh Send SMS

/** * [sendsms description] * @param [string] $tpl _content [SMS content sent] * @param $send _mobile [sent mobile phone number] */publi C function Sendsms ($tpl _content, $send _mobile) {$this->yunpian_appkey = env (' Yunpian_appkey ');//Cloud Slice account Appkey $this    ->yunpian_secret = env (' yunpiansecretxyz ');//Cloud Slice account Secret//initialization $ch = Curl_init ();    $data =array (' text ' = = $tpl _content, ' apikey ' + $this->yunpian_appkey, ' mobile ' = $send _mobile);    curl_setopt ($ch, Curlopt_url, ' Https://sms.yunpian.com/v2/sms/single_send.json ');    curl_setopt ($ch, Curlopt_postfields, Http_build_query ($data)); curl_setopt ($ch, Curlopt_httpheader, Array (' Accept:text/plain;charset=utf-8 ', ' content-type:application/    X-www-form-urlencoded ', ' charset=utf-8 '));    curl_setopt ($ch, Curlopt_returntransfer, true);    curl_setopt ($ch, Curlopt_timeout, 10);    curl_setopt ($ch, Curlopt_post, 1);    curl_setopt ($ch, Curlopt_ssl_verifypeer, false);    curl_setopt ($ch, Curlopt_postfields, Http_build_query ($data)); $senD_data = curl_exec ($ch);    Curl_close ($ch);    Parse the returned result (JSON format string) $backmassage = Json_decode ($send _data,true);    Echo ' $backmassage ';    This is written in the job, so I remember a log can be ignored!    Log::info (' Smsmessagelog: '. $send _data);  return [$backmassage, $send _data]; }

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.