欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php調(diào)用云片網(wǎng)接口發(fā)送短信的實(shí)現(xiàn)方法

 更新時間:2017年10月25日 08:50:43   作者:今天一點(diǎn)也不冷  
這篇文章主要介紹了php調(diào)用云片網(wǎng)接口發(fā)送短信的實(shí)現(xiàn)方法的相關(guān)資料,希望通過本文能幫助到大家,讓大家實(shí)現(xiàn)這樣的功能,需要的朋友可以參考下

php調(diào)用云片網(wǎng)接口發(fā)送短信的實(shí)現(xiàn)方法

云片網(wǎng)發(fā)送短信

/**
   * [SendSms description]
   * @param [string] $tpl_content [發(fā)送的短信內(nèi)容]
   * @param     $send_mobile [發(fā)送的手機(jī)號碼]
   */
  public function SendSms($tpl_content,$send_mobile)
  {
    $this->yunpian_appkey = env('yunpian_appkey');//云片賬戶appkey
    $this->yunpian_secret = env('yunpianSecretXYZ');//云片賬戶secret
    //初始化
    $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);
    //解析返回結(jié)果(json格式字符串)
    $backmassage = json_decode($send_data,true);
    echo '$backmassage ';
    //這里是寫在了job里面所以記了個日志可忽略!
    Log::info('smsmessagelog: '.$send_data);
    return [$backmassage,$send_data];
  }

云片短信接口文檔:http://www.yunpian.com/api2.0/api-domestic/single_send.html

如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

最新評論