kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

钉钉API

注册

https://open-dev.dingtalk.com

创建web应用

https://open.dingtalk.com/document/orgapp/microapplication-creation-and-release-process

API 下载, 样例

https://open.dingtalk.com/document/orgapp/how-to-call-apis

https://open.dingtalk.com/document/orgapp/download-the-server-side-sdk?spm=ding_open_doc.document.0.0.a599b17dPaKiMo

1
2
3
4
5
6
7
include "TopSdk.php";
// DingTalkConstant::$METHOD_GET 要与下面调用接口url要求的保持一致
$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_GET , DingTalkConstant::$FORMAT_JSON);
$req = new OapiUserGetRequest();
$req->setUserid("userid1");
$resp = $c->execute($req, $accessToken,"https://oapi.dingtalk.com/user/get");
var_dump($resp)
1
2
3
4
5
6
7
8
9
10
11
12
// 获取部门列表
function DepartmentListsub($depid = 1)
{
	$accessToken = $this->gettoken();

	$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
	$req = new OapiV2DepartmentListsubRequest();
	$req->setDeptId($depid);
	$req->setLanguage("zh_CN");
	$resp = $c->execute($req, $accessToken, "https://oapi.dingtalk.com/topapi/v2/department/listsub");
	var_dump($resp);
}

发送工作通知

https://open.dingtalk.com/document/orgapp/asynchronous-sending-of-enterprise-session-messages

点击工作通知跳转到网页应用

https://open.dingtalk.com/document/orgapp/redirect-micro-applications-to-work-messages

1
2
3
4
5
6
7
8
9
10
function gettoken()
{
	$cget = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_GET , DingTalkConstant::$FORMAT_JSON);
	$req = new OapiGettokenRequest();
	$req->setAppkey($this->ClientID);
	$req->setAppsecret($this->ClientSecret);
	$resp = $cget->execute($req, '', "https://oapi.dingtalk.com/gettoken");
	// var_dump($resp);
	return $resp->access_token;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// 发送工作通知
function MessageCorpconversationAsyncsendV2()
{
	$accessToken = $this->gettoken();

	$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);

	$req = new OapiMessageCorpconversationAsyncsendV2Request();
	$req->setAgentId($this->AgentId);
	$req->setUseridList('045961');
	$req->setToAllUser(false);

	/*
	$msg = array(
		"msgtype" => "text",
		"text" => ["content"=>"12333"],
		);
	*/
	/*
	$msg = array(
		"msgtype" => "link",
		"link" => [
			"picUrl" => "https://a.com/g.png",
			"messageUrl" => "https://a.com/aa",
			"text" => "text",
			"title" => "title"
			]
		);
	*/
	$msg = array(
		"msgtype" => "link",
		"link" => [
			"picUrl" => "https://a.com/g.png",
			"messageUrl" => "dingtalk://dingtalkclient/action/openapp?corpid={$this->corpId}&container_type=work_platform&app_id=0_{$this->AgentId}&redirect_type=jump&redirect_url=https://a.com/aaa",
			"text" => "text",
			"title" => "title"
			]
		);
	$req->setMsg($msg);

	$resp = $c->execute($req, $accessToken, "https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2");
	var_dump($resp);
}

批量发送人与机器人会话中机器人消息

https://open.dingtalk.com/document/orgapp/chatbots-send-one-on-one-chat-messages-in-batches

通过免登码获取用户信息

https://open.dingtalk.com/document/orgapp/obtain-the-userid-of-a-user-by-using-the-log-free

https://open.dingtalk.com/document/orgapp/jsapi-get-auth-code

https://open.dingtalk.com/document/orgapp/webapp-read-before-development

只能用js获取code???

跳转不太和谐

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function auth($startpage = 0)
{
	echo "555<br>";
	echo "<div id='cc'>444</div>";
	echo "<div id='dd'>444</div>";
	echo '<script src="https://g.alicdn.com/dingding/dingtalk-jsapi/3.0.25/dingtalk.open.js"></script>';
	//echo "<script> dd.getAuthCode({ corpId: 'ding07018e',  success: (res) => { document.getElementById('cc').innerHTML = res.code; }, }); document.getElementById('dd').innerHTML = 'ff'; </script>";
	// echo "<script> dd.replacePage({ url: 'http://www.baidu.com' }); /* dd.closePage(); */ </script>";
	echo "<script> dd.getAuthCode({ corpId: 'ding07018e',  success: (res) => { dd.openLink({url: 'https://a.com/ding/getuserinfo?code='+res.code }); dd.closePage(); }, }); document.getElementById('dd').innerHTML = 'ff'; </script>";

	// 根据 code access_token 获取免密用户信息
	// curl -X POST -d "code=75e121d18" "https://oapi.dingtalk.com/topapi/v2/user/getuserinfo?access_token=6c53ee68"

	echo "666<br>";
}

// 获取免密用户信息
function getuserinfo()
{
	$code = $this->input->get('code');

	$accessToken = $this->gettoken();

	$url = "https://oapi.dingtalk.com/topapi/v2/user/getuserinfo?access_token={$accessToken}";

	$header = array('Content-Type: application/json');
	$fields = array('code' => $code);
	$postfields = json_encode($fields);
	$res = $this->Wxapi_model->queryUrl($url, $header, $postfields);
	$res = json_decode($res, true);
	if (isset($res['errcode']) and $res['errcode'] == 0) {
		echo $res['errmsg'], "<br><br>";
		var_dump($res['result']['userid']);
		echo "<br><br>";
		var_dump($res['result']);
		echo "<br><br>";
	}
	var_dump($res);
}

system, base

« unhide 搜寻隐藏进程, 挖矿病毒处理 gps WGS84与GCJ02经纬度坐标转换 wx.getLocation »