PHP Sky-wing open platform SMS Send Interface implementation method, PHP SMS send _php Tutorial

Source: Internet
Author: User
Tags sha1

PHP Sky-wing open platform SMS Send Interface implementation method, PHP SMS Send


This paper introduces the implementation method of PHP sky-wing open platform SMS sending interface. Share to everyone for your reference. The specific analysis is as follows:

Temporary needs, research the day Wing development platform of things, used to send a verification code or good, but the daily limit is not much, so very chicken, but to ensure that 100% to buy the words are still very expensive, the code did not do any optimization processing, just test can be implemented interface, with the students remember the perfect code, Just finished the eldest brother said is the chicken, no, the code is placed in the blog record, the code is as follows:
Copy CodeThe code is as follows: <?php
//
Date_default_timezone_set (' PRC ');
Get Access_token
$data = "App_id=x&app_secret=x&grant_type=client_credentials";
$ch = Curl_init ("Https://oauth.api.189.cn/emp/oauth2/v2/access_token");
curl_setopt ($ch, curlopt_returntransfer,1);
curl_setopt ($ch, curlopt_post,1);//use POST to submit data
curl_setopt ($ch, Curlopt_postfields, $data);//Set post-submitted data
curl_setopt ($ch, Curlopt_ssl_verifypeer, false);
Check that the SSL encryption algorithm exists from the certificate

curl_setopt ($ch, Curlopt_ssl_verifyhost, false);
$access _token = curl_exec ($ch);
Curl_close ($ch);
$access _token = Json_decode ($access _token,true);
Get SMS Trust code
$timestamp = Date (' y-m-d h:i:s ');

$param [' app_id '] = "app_id=x";
$param [' access_token '] = "access_token=". $access _token[' Access_token '];
$param [' timestamp '] = "timestamp=". $timestamp;
Ksort ($param);
$plaintext = Implode ("&", $param);
$sign = Rawurlencode (Base64_encode (Hash_hmac (' SHA1 ', $plaintext, app_secret,true)));
echo $sign; exit;
$code = file_get_contents ("http://api.189.cn/v2/dm/randcode/token?app_id=x&access_token={$access _token[" Access_token ']}&timestamp= '. $timestamp. " &sign= ". $sign);
$code = Json_decode ($code, true);
$code = $code [' token '];
Echo $code;
Issued Verification code
Unset ($param, $plaintext, $sign);
$param [' app_id '] = "app_id=x";
$param [' access_token '] = "access_token=". $access _token[' Access_token '];
$param [' token '] = "token=". $code;
$param [' phone '] = "phone=15091421612";
$param [' url '] = "url=http://wx.podapi.com/test.php";
$param [' exp_time '] = "exp_time=2";
$param [' timestamp '] = "timestamp=". $timestamp;
Ksort ($param);
$plaintext = Implode ("&", $param);
$sign = Rawurlencode (Base64_encode (Hash_hmac (' SHA1 ', $plaintext, ' xx ', true)));

$data = "app_id=x&access_token={$access _token[' access_token ']}&token={$code}&phone=15091421612& url=http://wx.podapi.com/test.php&exp_time=2&timestamp={$timestamp}&sign= ". $sign;
$ch = Curl_init ("Http://api.189.cn/v2/dm/randcode/send");
curl_setopt ($ch, curlopt_returntransfer,1);
curl_setopt ($ch, curlopt_post,1);//use POST to submit data
curl_setopt ($ch, Curlopt_postfields, $data);//Set post-submitted data
curl_setopt ($ch, Curlopt_ssl_verifypeer, false);
Check that the SSL encryption algorithm exists from the certificate
curl_setopt ($ch, Curlopt_ssl_verifyhost, false);
$state = curl_exec ($ch);
Var_dump (Curl_getinfo ($ch));
Curl_close ($ch);
Echo $state;
?>

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/931543.html www.bkjia.com true http://www.bkjia.com/PHPjc/931543.html techarticle PHP Day-wing open platform SMS Send Interface implementation method, PHP text message sent in this article on the PHP Day-wing open platform SMS delivery interface implementation method. Share to everyone for your reference. Specific ...

  • Related Article

    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.