zoukankan      html  css  js  c++  java
  • 接口调用 POST

    /**
    * 接口调用 POST
    * @return [type] [description]
    */
    public function portPhone(Request $request)
    {
      $phone = $request->input('phone');

      $random = rand(100000,999999);

      $randoms = session::put('random',$random);


      $url = 'http://api.chanyoo.cn/utf8/interface/send_sms.aspx';

      $data = array('username'=>'张三',
        'password'=>'***********',
        'receiver'=>$phone,
        'content'=>'您的手机号:'.$phone.',绑定验证码:'.$random.'。一天内提交有效!【****】'

      );

      $postdata = http_build_query($data);

      //请求头信息、请求参数、请求方式
      $opts = array(
        'http' =>
          array(
            'method' => 'POST',
            'header' => 'Content-type: application/x-www-form-urlencoded',
            'content' => $postdata
          )
        );

      $context = stream_context_create($opts);

      $result = file_get_contents($url, false, $context);

       return $result;

    }

  • 相关阅读:
    uniapp请求拦截
    stellar视差插件
    fullpage全屏插件应用
    fullpage全屏插件简介
    WdatePicker日期插件
    Ueditor富文本编辑器
    layer弹出层
    验证码绘制
    Ajax跨域访问
    JQuery封装的ajax方法
  • 原文地址:https://www.cnblogs.com/54sen/p/6729208.html
Copyright © 2011-2022 走看看