Commit cdf7e0be authored by 梁俊杰's avatar 梁俊杰

1

parent c85fd1d9
......@@ -32,13 +32,22 @@ $config = [
// DingTalkConstant::$METHOD_GET 要与下面调用接口url要求的保持一致
$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_GET , DingTalkConstant::$FORMAT_JSON);
$req = new OapiGettokenRequest();
$req->setAppkey($config['app_key']);
$req->setAppsecret($config['app_secret']);
/*$req->setCorpid($config['corp_id']);
$req->setCorpsecret($config['corp_secret']);*/
$res = $c->execute($req,null,'https://oapi.dingtalk.com/gettoken');
$token = $res->access_token;
//$resp=$c->execute($req, $accessToken,"https://oapi.dingtalk.com/user/get");
var_dump($token);
if(isset($users[$data['assignedTo']])){
$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_GET , DingTalkConstant::$FORMAT_JSON);
$req = new OapiGettokenRequest();
$req->setAppkey($config['app_key']);
$req->setAppsecret($config['app_secret']);
$res = $c->execute($req,null,'https://oapi.dingtalk.com/gettoken');
$token = $res->access_token;
$message = '{"msgtype":"markdown","text":{"content":"'.$data['text'].'"}}';
$req = new OapiMessageCorpconversationAsyncsendV2Request();
$req->setAgentId('326099394');
$req->setToAllUser(false);
$req->setUseridList($users[$data['assignedTo']]['userid']);
$req->setMsg($message);
$c->execute($req, null,'https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token='.$token);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment