首页 > 代码库 > 接口调用 POST
接口调用 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 = http://www.mamicode.com/array(‘username‘=>‘张三‘,
‘password‘=>‘***********‘,
‘receiver‘=>$phone,
‘content‘=>‘您的手机号:‘.$phone.‘,绑定验证码:‘.$random.‘。一天内提交有效!【****】‘
);
$postdata = http://www.mamicode.com/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;
}
接口调用 POST