php发送钉钉消息,模板例子
<?php #key 与secret私钥 $appkey = "ding6prlu53np9e6ly0vv2"; $appsecret = "KW9_HiBHyLs5YYgb0zfHd3uAvtrbbMZy5bv5eEsQzzctA9nbZjk6KuEMudJFWllVeI"; //请求token $url = "https://oapi.dingtalk.com/gettoken?appkey=$appkey&appsecret=$appsecret"; $res = file_get_contents($url); var_dump($res);
获取到token值
获取到token
//更新模板 $url = "https://oapi.dingtalk.com/topapi/process/save"; $postUrl = $url . "?access_token=$access_token"; $data = [ "saveProcessRequest"=>'{ "agentid":"1708075901", "process_code":"PROC-DB3CCEC6-2F5F-4A09-8832-03E35FC74703", "name":"代付测试", "form_component_list":[ { "component_name":"TextField", "props":{ "required": true, "id":"TextField-J78F056R", "label":"收款账户" } }, { "component_name": "MoneyField", "props": { "required": true, "label": "金额(元)", "id": "MoneyField-J78F0571", } }, ] }' ]; $curl = curl_init(); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_URL, $postUrl); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $res = curl_exec($curl); curl_close($curl); var_dump($res); exit();