zoukankan      html  css  js  c++  java
  • php服务器网络请求

    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
  • 相关阅读:
    结构体的malloc与数组空间
    绘制K线图
    加载文件
    数据分析(绘图)
    GIT操作
    疑难杂症汇总
    Shell编程2
    shell编程1
    shell命令2
    Shell命令1
  • 原文地址:https://www.cnblogs.com/bluestear/p/11228211.html
Copyright © 2011-2022 走看看