PHP版钉钉发起审批实例

开发API文档
https://ding-doc.dingtalk.com/doc#/serverapi2/cmct1a

 

function create_process_instance()
{
	
    $access_token = getAccessToken(APP_KEY, APP_SECRET); //正常情况下access_token有效期为7200秒,有效期内重复获取返回相同结果,并自动续期。
	$process_code = "PROC-EEEEDFF0-E81B-450B-A32E-0FE1CA6457C1";//服务监测计划
	$originator_user_id ="053066671332391176"; //"originator_userid"
	$dept_id ="123098269";//"originator_dept_id"
	
	//明细
    $detail =array(array(array('name' => '单行输入框', 'value' => '部门级'),array('name' => '数字输入框', 'value' => '123')),array(array('name' => '单行输入框', 'value' => '部门级2'),array('name' => '数字输入框', 'value' => '345')));
    
    $form_component_values =array(array('name' => '级别', 'value' => '部门级'), //单选
	                              array('name' => '["监测开始时间","监测结束时间"]', 'value' => '["2019-09-10 10:32","2019-10-10 10:36"]'),//日期区间
								  array('name' => '监察人员', 'value' => '["黄变庆","孙大伟"]'), //多选
								  array('name' => '明细', 'value' => $detail) ); //明细

	$data = array("process_code" => $process_code, "originator_user_id" => $originator_user_id,"dept_id" => $dept_id,"form_component_values" => $form_component_values);
	print_r($data);
	
    $webhook = "https://oapi.dingtalk.com/topapi/processinstance/create?access_token=" . $access_token;
    $result = request_by_curl($webhook, json_encode($data));
    return $result;
}

 

你可能感兴趣的:(PHP)