标签 php 下的文章

 function list(){
        $url = '接口地址';
        $sign = strtoupper(md5('0001加密字符'));
        $postData = [
           'deptId' => '0001',
           'sign' => $sign
        ];
        $options = [
            'http' => [
                'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
                'method'  => 'POST',
                'content' => http_build_query($postData)
            ]
        ];
        $context = stream_context_create($options);
        // 发送请求并获取响应
        $response = file_get_contents($url, false, $context);
        if ($response === false) {
            // 处理错误
           JsonReturn(['code'=>1,'msg'=>'接口服务网络出错!']);
        } else {
            //$json = json_encode($response);
            //JsonReturn(['code'=>0,'data'=>$json]);
            echo $response;
        }
}