<?
function getSign($params, $appSecret) {
$params['app_secret'] = $appSecret;
ksort($params);
$queryString = http_build_query($params);
return md5($queryString);
}
function getToken($appId, $appSecret, $time) {
$url = "http://tdrj.tpddns.cn:1025/api/admin/user/login";
$params = [
'app_id' => $appId,
'time' => $time
];
$sign = getSign($params, $appSecret);
$params['sign'] = $sign;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'AuthType: Integration'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
$response = curl_exec($ch);
$tokenData=json_decode($response,true);
$token = $tokenData['data']['access_token'] ?? null;
return $token;
curl_close($ch);
}
function callUserMsgApi($token, $params) {
$url = "http://tdrj.tpddns.cn:1025/api/flow/FlowManager/workQuery";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'AuthType: Integration',
'UserId:1',//用户id
'AccessToken: ' . $token
]);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
$r= curl_exec($ch);
return $r;
curl_close($ch);
}
$appId = "9tWhbjSZfDlaAo0n";
$appSecret = '#nv9bFHXTasZ$PKG1rf6uDjJUQc84i';
$time = time();
$token = getToken($appId, $appSecret, $time);
$getData = '{"filter":{"flow_data":{},"desc_OP":"like","type_OP":"like","run_name_OP":"like","create_time_OP":[">","<"],"update_time_OP":[">","<"]},"search_OP":"like","sort":{"update_time":"DESC"},"limit":10,"page":1,"search":"亮","flow_cate_id":""}';
$a=json_decode($getData,true);
print_r($a);
$r=callUserMsgApi($token, $getData);
print_r(json_decode($r));