首页 > Web开发 > 详细

php服务器网络请求

时间:2019-07-22 20:57:40      阅读:97      评论:0      收藏:0      [点我收藏+]

1,get方法

$result = file_get_contents($personUrl);

2,post方法,使用querystring,使用json

$personUrl="http://www.wacloud.net/open/persion/insert?appid=$doorAppid&sign=$sign&timestamp=$timestamp";

$info=array(
‘canAttence‘=>true,
‘canPass‘=>true,
‘card‘=>$cardNum,
‘deptIdList‘=>[6330],
‘effectEndTime‘=>"2019-07-28 02:10:39.305Z",
‘effectStartTime‘=>"2019-07-20 02:10:39.305Z",
‘mobile‘=>"18866668888",
‘name‘=>"临时访客",
‘openType‘=>2,
‘persionType‘=>2,
‘status‘=>0,
);

$context = stream_context_create(array(
‘http‘ => array(‘method‘ => ‘POST‘,
‘header‘ => ‘Content-Type:application/json‘,
‘content‘ => json_encode($info),
‘timeout‘ => 20 )
));

 

$context = stream_context_create(array( 
‘http‘ => array(‘method‘ => ‘POST‘,
‘header‘ => ‘Content-Type:application/x-www-form-urlencoded‘,

‘content‘ => http_build_query($info), 

‘timeout‘ => 20 ) 
)); 
$result = file_get_contents($personUrl,false, $context);

 



print_r($result);

http_build_query

php服务器网络请求

原文:https://www.cnblogs.com/bluestear/p/11228211.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!