公司最近在做建筑实名制对接,特分享此代码给需要的人。
<?php
namespace app\common\library;
use fast\Random;
use think\Hook;
use fast\Http;
use app\common\library\Aes;
use think\Db;
/**
* 天津建委实名制
*/
class Tjjw
{
# 对接网址
protected static $apiurl = 'https://111.164.113.170:8081/openapi/open.api';
# 请求封装成一个方法
public static function postdata($appid, $secret, $method, $body)// id 秘钥 请求方法 内容
{
$headers = [
"Content-Type: application/json; charset=utf-8",
];
# 时间戳
$timestamp = date('YmdHis', time());
# 随机字符
$nonce = self::randstrpay();
$strdata = json_encode($body);
$data=[
"appid" => $appid,
"data" => $strdata,
"format" => 'json',
"met