| 1 | package QQ::weixin::work::wedoc; | ||
| 2 | |||
| 3 | =encoding utf8 | ||
| 4 | |||
| 5 | =head1 Name | ||
| 6 | |||
| 7 | QQ::weixin::work::wedoc | ||
| 8 | |||
| 9 | =head1 DESCRIPTION | ||
| 10 | |||
| 11 | 文档 | ||
| 12 | |||
| 13 | =cut | ||
| 14 | |||
| 15 | use strict; | ||
| 16 | use base qw(QQ::weixin::work); | ||
| 17 | use Encode; | ||
| 18 | use LWP::UserAgent; | ||
| 19 | use JSON; | ||
| 20 | use utf8; | ||
| 21 | |||
| 22 | our $VERSION = '0.10'; | ||
| 23 | our @EXPORT = qw/ create_doc rename_doc del_doc get_doc_base_info doc_share | ||
| 24 | doc_get_auth mod_doc_join_rule mod_doc_member mod_doc_safty_setting | ||
| 25 | create_form modify_form get_form_info get_form_statistic get_form_answer | ||
| 26 | file_acl_del file_setting file_share /; | ||
| 27 | |||
| 28 | =head1 FUNCTION | ||
| 29 | |||
| 30 | 管理文档 | ||
| 31 | |||
| 32 | =head2 create_doc(access_token, hash); | ||
| 33 | |||
| 34 | 新建文档 | ||
| 35 | 最后更新:2023/11/08 | ||
| 36 | |||
| 37 | =head2 SYNOPSIS | ||
| 38 | |||
| 39 | L<https://developer.work.weixin.qq.com/document/path/97460> | ||
| 40 | |||
| 41 | =head3 请求说明: | ||
| 42 | |||
| 43 | 该接口用于新建文档和表格,新建收集表可前往 收集表管理 查看。 | ||
| 44 | |||
| 45 | =head4 请求包结构体为: | ||
| 46 | |||
| 47 | { | ||
| 48 | "spaceid": "SPACEID", | ||
| 49 | "fatherid": "FATHERID", | ||
| 50 | "doc_type": "DOC_TYPE", | ||
| 51 | "doc_name": "DOC_NAME", | ||
| 52 | "admin_users": ["USERID1", "USERID2", "USERID3"] | ||
| 53 | } | ||
| 54 | |||
| 55 | =head4 参数说明: | ||
| 56 | |||
| 57 | 参数 类型 是否必须 说明 | ||
| 58 | access_token 是 调用接口凭证 | ||
| 59 | spaceid string 否 空间spaceid。若指定spaceid,则fatherid也要同时指定 | ||
| 60 | fatherid string 否 父目录fileid, 在根目录时为空间spaceid | ||
| 61 | doc_type uint32 是 文档类型, 3:文档 4:表格 | ||
| 62 | doc_name string 是 文档名字(注意:文件名最多填255个字符, 超过255个字符会被截断) | ||
| 63 | admin_users string[] 否 文档管理员userid | ||
| 64 | |||
| 65 | =head4 权限说明: | ||
| 66 | |||
| 67 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 68 | 第三方应用需具有“文档”权限 | ||
| 69 | 代开发自建应用需具有“文档”权限 | ||
| 70 | |||
| 71 | =head3 RETURN 返回结果: | ||
| 72 | |||
| 73 | { | ||
| 74 | "errcode": 0, | ||
| 75 | "errmsg": "ok", | ||
| 76 | "url": "URL", | ||
| 77 | "docid": "DOCID" | ||
| 78 | } | ||
| 79 | |||
| 80 | =head4 RETURN 参数说明: | ||
| 81 | |||
| 82 | 参数 类型 说明 | ||
| 83 | errcode int32 错误码 | ||
| 84 | errmsg string 错误码说明 | ||
| 85 | url string 新建文档的访问链接 | ||
| 86 | docid string 新建文档的docid | ||
| 87 | |||
| 88 | =cut | ||
| 89 | |||
| 90 | sub create_doc { | ||
| 91 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 92 | my $access_token = $_[0]; | ||
| 93 | my $json = $_[1]; | ||
| 94 | my $ua = LWP::UserAgent->new; | ||
| 95 | $ua->timeout(30); | ||
| 96 | $ua->env_proxy; | ||
| 97 | |||
| 98 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/create_doc?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 99 | if ($response->is_success) { | ||
| 100 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 101 | } | ||
| 102 | |||
| 103 | } | ||
| 104 | return 0; | ||
| 105 | } | ||
| 106 | |||
| 107 | =head2 rename_doc(access_token, hash); | ||
| 108 | |||
| 109 | 重命名文档/收集表 | ||
| 110 | 最后更新:2022/12/09 | ||
| 111 | |||
| 112 | =head2 SYNOPSIS | ||
| 113 | |||
| 114 | L<https://developer.work.weixin.qq.com/document/path/97736> | ||
| 115 | |||
| 116 | =head3 请求说明: | ||
| 117 | |||
| 118 | 该接口用于对指定文档/收集表进行重命名。 | ||
| 119 | |||
| 120 | =head4 请求包结构体为: | ||
| 121 | |||
| 122 | { | ||
| 123 | "docid": "DOCID", | ||
| 124 | "formid": "FORMID", | ||
| 125 | "new_name": "NEW_NAME" | ||
| 126 | } | ||
| 127 | |||
| 128 | =head4 参数说明: | ||
| 129 | |||
| 130 | 参数 类型 是否必须 说明 | ||
| 131 | access_token 是 调用接口凭证 | ||
| 132 | docid string 否 文档docid(docid、formid只能填其中一个) | ||
| 133 | formid string 否 收集表id(docid、formid只能填其中一个) | ||
| 134 | new_name string 是 重命名后的文档名 (注意:文档名最多填255个字符, 英文算1个, 汉字算2个, 超过255个字符会被截断) | ||
| 135 | |||
| 136 | =head4 权限说明: | ||
| 137 | |||
| 138 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 139 | 第三方应用需具有“文档”权限 | ||
| 140 | 代开发自建应用需具有“文档”权限 | ||
| 141 | |||
| 142 | =head3 RETURN 返回结果: | ||
| 143 | |||
| 144 | { | ||
| 145 | "errcode": 0, | ||
| 146 | "errmsg": "ok" | ||
| 147 | } | ||
| 148 | |||
| 149 | =head4 RETURN 参数说明: | ||
| 150 | |||
| 151 | 参数 类型 说明 | ||
| 152 | errcode int32 错误码 | ||
| 153 | errmsg string 错误码说明 | ||
| 154 | |||
| 155 | =cut | ||
| 156 | |||
| 157 | sub rename_doc { | ||
| 158 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 159 | my $access_token = $_[0]; | ||
| 160 | my $json = $_[1]; | ||
| 161 | my $ua = LWP::UserAgent->new; | ||
| 162 | $ua->timeout(30); | ||
| 163 | $ua->env_proxy; | ||
| 164 | |||
| 165 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/rename_doc?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 166 | if ($response->is_success) { | ||
| 167 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 168 | } | ||
| 169 | |||
| 170 | } | ||
| 171 | return 0; | ||
| 172 | } | ||
| 173 | |||
| 174 | =head2 del_doc(access_token, hash); | ||
| 175 | |||
| 176 | 删除文档/收集表 | ||
| 177 | 最后更新:2022/12/09 | ||
| 178 | |||
| 179 | =head2 SYNOPSIS | ||
| 180 | |||
| 181 | L<https://developer.work.weixin.qq.com/document/path/97735> | ||
| 182 | |||
| 183 | =head3 请求说明: | ||
| 184 | |||
| 185 | 该接口用于删除指定文档/收集表。 | ||
| 186 | |||
| 187 | =head4 请求包结构体为: | ||
| 188 | |||
| 189 | { | ||
| 190 | "docid": "DOCID", | ||
| 191 | "formid": "FORMID" | ||
| 192 | } | ||
| 193 | |||
| 194 | =head4 参数说明: | ||
| 195 | |||
| 196 | 参数 类型 是否必须 说明 | ||
| 197 | access_token 是 调用接口凭证 | ||
| 198 | docid string 否 文档docid(docid、formid只能填其中一个) | ||
| 199 | formid string 否 收集表id(docid、formid只能填其中一个) | ||
| 200 | |||
| 201 | =head4 权限说明: | ||
| 202 | |||
| 203 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 204 | 第三方应用需具有“文档”权限 | ||
| 205 | 代开发自建应用需具有“文档”权限 | ||
| 206 | |||
| 207 | =head3 RETURN 返回结果: | ||
| 208 | |||
| 209 | { | ||
| 210 | "errcode": 0, | ||
| 211 | "errmsg": "ok" | ||
| 212 | } | ||
| 213 | |||
| 214 | =head4 RETURN 参数说明: | ||
| 215 | |||
| 216 | 参数 类型 说明 | ||
| 217 | errcode int32 错误码 | ||
| 218 | errmsg string 错误码说明 | ||
| 219 | |||
| 220 | =cut | ||
| 221 | |||
| 222 | sub del_doc { | ||
| 223 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 224 | my $access_token = $_[0]; | ||
| 225 | my $json = $_[1]; | ||
| 226 | my $ua = LWP::UserAgent->new; | ||
| 227 | $ua->timeout(30); | ||
| 228 | $ua->env_proxy; | ||
| 229 | |||
| 230 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/del_doc?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 231 | if ($response->is_success) { | ||
| 232 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 233 | } | ||
| 234 | |||
| 235 | } | ||
| 236 | return 0; | ||
| 237 | } | ||
| 238 | |||
| 239 | =head2 get_doc_base_info(access_token, hash); | ||
| 240 | |||
| 241 | 获取文档基础信息 | ||
| 242 | 最后更新:2022/12/09 | ||
| 243 | |||
| 244 | =head2 SYNOPSIS | ||
| 245 | |||
| 246 | L<https://developer.work.weixin.qq.com/document/path/97734> | ||
| 247 | |||
| 248 | =head3 请求说明: | ||
| 249 | |||
| 250 | 该接口用于获取指定文档的基础信息。 | ||
| 251 | |||
| 252 | =head4 请求包结构体为: | ||
| 253 | |||
| 254 | { | ||
| 255 | "docid": "DOCID" | ||
| 256 | } | ||
| 257 | |||
| 258 | =head4 参数说明: | ||
| 259 | |||
| 260 | 参数 类型 是否必须 说明 | ||
| 261 | access_token 是 调用接口凭证 | ||
| 262 | docid string 否 文档docid | ||
| 263 | |||
| 264 | =head4 权限说明: | ||
| 265 | |||
| 266 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 267 | 第三方应用需具有“文档”权限 | ||
| 268 | 代开发自建应用需具有“文档”权限 | ||
| 269 | |||
| 270 | =head3 RETURN 返回结果: | ||
| 271 | |||
| 272 | { | ||
| 273 | "errcode": 0, | ||
| 274 | "errmsg": "ok", | ||
| 275 | "doc_base_info": { | ||
| 276 | "docid": "DOCID", | ||
| 277 | "doc_name": "DOC_NAME", | ||
| 278 | "create_time": CREATE_TIME, | ||
| 279 | "modify_time": MODIFY_TIME, | ||
| 280 | "doc_type": DOC_TYPE | ||
| 281 | } | ||
| 282 | } | ||
| 283 | |||
| 284 | =head4 RETURN 参数说明: | ||
| 285 | |||
| 286 | 参数 类型 说明 | ||
| 287 | errcode int32 错误码 | ||
| 288 | errmsg string 错误码说明 | ||
| 289 | docid string 文档docid | ||
| 290 | doc_name string 文档名字 | ||
| 291 | create_time uint64 文档创建时间 | ||
| 292 | modify_time uint64 文档最后修改时间 | ||
| 293 | doc_type uint32 3: 文档 4: 表格 | ||
| 294 | |||
| 295 | =cut | ||
| 296 | |||
| 297 | sub get_doc_base_info { | ||
| 298 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 299 | my $access_token = $_[0]; | ||
| 300 | my $json = $_[1]; | ||
| 301 | my $ua = LWP::UserAgent->new; | ||
| 302 | $ua->timeout(30); | ||
| 303 | $ua->env_proxy; | ||
| 304 | |||
| 305 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/get_doc_base_info?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 306 | if ($response->is_success) { | ||
| 307 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 308 | } | ||
| 309 | |||
| 310 | } | ||
| 311 | return 0; | ||
| 312 | } | ||
| 313 | |||
| 314 | =head2 doc_share(access_token, hash); | ||
| 315 | |||
| 316 | 分享文档 | ||
| 317 | 最后更新:2022/12/09 | ||
| 318 | |||
| 319 | =head2 SYNOPSIS | ||
| 320 | |||
| 321 | L<https://developer.work.weixin.qq.com/document/path/97733> | ||
| 322 | |||
| 323 | =head3 请求说明: | ||
| 324 | |||
| 325 | 该接口用于获取文档的分享链接。 | ||
| 326 | |||
| 327 | =head4 请求包结构体为: | ||
| 328 | |||
| 329 | { | ||
| 330 | "docid": "DOCID", | ||
| 331 | "formid": "FORMID" | ||
| 332 | } | ||
| 333 | |||
| 334 | =head4 参数说明: | ||
| 335 | |||
| 336 | 参数 类型 是否必须 说明 | ||
| 337 | access_token 是 调用接口凭证 | ||
| 338 | docid string 否 文档docid(docid、formid只能填其中一个) | ||
| 339 | formid string 否 收集表id(docid、formid只能填其中一个) | ||
| 340 | |||
| 341 | =head4 权限说明: | ||
| 342 | |||
| 343 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 344 | 第三方应用需具有“文档”权限 | ||
| 345 | 代开发自建应用需具有“文档”权限 | ||
| 346 | 只能访问该应用创建的文档 | ||
| 347 | |||
| 348 | =head3 RETURN 返回结果: | ||
| 349 | |||
| 350 | { | ||
| 351 | "errcode":0, | ||
| 352 | "errmsg":"ok", | ||
| 353 | "share_url":"URL1" | ||
| 354 | } | ||
| 355 | |||
| 356 | =head4 RETURN 参数说明: | ||
| 357 | |||
| 358 | 参数 类型 说明 | ||
| 359 | errcode int32 错误码 | ||
| 360 | errmsg string 错误码说明 | ||
| 361 | share_url string 文档分享链接 | ||
| 362 | |||
| 363 | =cut | ||
| 364 | |||
| 365 | sub doc_share { | ||
| 366 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 367 | my $access_token = $_[0]; | ||
| 368 | my $json = $_[1]; | ||
| 369 | my $ua = LWP::UserAgent->new; | ||
| 370 | $ua->timeout(30); | ||
| 371 | $ua->env_proxy; | ||
| 372 | |||
| 373 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/doc_share?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 374 | if ($response->is_success) { | ||
| 375 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 376 | } | ||
| 377 | |||
| 378 | } | ||
| 379 | return 0; | ||
| 380 | } | ||
| 381 | |||
| 382 | =head1 FUNCTION | ||
| 383 | |||
| 384 | 设置文档权限 | ||
| 385 | |||
| 386 | =head2 doc_get_auth(access_token, hash); | ||
| 387 | |||
| 388 | 获取文档权限信息 | ||
| 389 | 最后更新:2022/12/09 | ||
| 390 | |||
| 391 | =head2 SYNOPSIS | ||
| 392 | |||
| 393 | L<https://developer.work.weixin.qq.com/document/path/97461> | ||
| 394 | |||
| 395 | =head3 请求说明: | ||
| 396 | |||
| 397 | 该接口用于获取文档的查看规则、文档通知范围及权限、安全设置信息 | ||
| 398 | |||
| 399 | =head4 请求包结构体为: | ||
| 400 | |||
| 401 | { | ||
| 402 | "docid":"DOCID" | ||
| 403 | } | ||
| 404 | |||
| 405 | =head4 参数说明: | ||
| 406 | |||
| 407 | 参数 类型 是否必须 说明 | ||
| 408 | access_token 是 调用接口凭证 | ||
| 409 | docid string 是 文档id | ||
| 410 | |||
| 411 | =head4 权限说明: | ||
| 412 | |||
| 413 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 414 | 第三方应用需具有“文档”权限 | ||
| 415 | 代开发自建应用需具有“文档”权限 | ||
| 416 | 只能访问该应用创建的文档 | ||
| 417 | |||
| 418 | =head3 RETURN 返回结果: | ||
| 419 | |||
| 420 | { | ||
| 421 | "errcode":0, | ||
| 422 | "errmsg":"ok", | ||
| 423 | "access_rule":{ | ||
| 424 | "enable_corp_internal":true, | ||
| 425 | "corp_internal_auth":1, | ||
| 426 | "enable_corp_external":true, | ||
| 427 | "corp_external_auth":1, | ||
| 428 | "corp_internal_approve_only_by_admin":true, | ||
| 429 | "corp_external_approve_only_by_admin":true, | ||
| 430 | "ban_share_external":false | ||
| 431 | }, | ||
| 432 | "secure_setting":{ | ||
| 433 | "enable_readonly_copy":false, | ||
| 434 | "watermark":{ | ||
| 435 | "margin_type":2, | ||
| 436 | "show_visitor_name":false, | ||
| 437 | "show_text":false, | ||
| 438 | "text":"" | ||
| 439 | }, | ||
| 440 | "enable_readonly_comment":false | ||
| 441 | }, | ||
| 442 | "doc_member_list":[ | ||
| 443 | { | ||
| 444 | "type":1, | ||
| 445 | "userid":"USERID1", | ||
| 446 | "auth":7 | ||
| 447 | }, | ||
| 448 | { | ||
| 449 | "type":1, | ||
| 450 | "tmp_external_userid":"TMP_EXTERNAL_USERID2", | ||
| 451 | "auth":1 | ||
| 452 | } | ||
| 453 | ], | ||
| 454 | "co_auth_list":[ | ||
| 455 | { | ||
| 456 | "type":2, | ||
| 457 | "departmentid":DEPARTMENTID1, | ||
| 458 | "auth":1 | ||
| 459 | } | ||
| 460 | ] | ||
| 461 | } | ||
| 462 | |||
| 463 | =head4 RETURN 参数说明: | ||
| 464 | |||
| 465 | 参数 类型 说明 | ||
| 466 | errcode int32 错误码 | ||
| 467 | errmsg string 错误码说明 | ||
| 468 | access_rule object 文档的查看规则 | ||
| 469 | enable_corp_internal bool 是否允许企业内成员浏览文档 | ||
| 470 | corp_internal_auth uint32 企业内成员主动查看文档后获得的权限类型 1:只读 | ||
| 471 | enable_corp_external bool 是否允许企业外成员浏览文档 | ||
| 472 | corp_external_auth uint32 企业内成员主动查看文档后获得的权限类型 1:只读 | ||
| 473 | corp_internal_approve_only_by_admin bool 企业内成员浏览文档是否必须由管理员审批,enable_corp_internal为false时,只能为true | ||
| 474 | corp_external_approve_only_by_admin bool 企业外成员浏览文档是否必须由管理员审批,enable_corp_external和ban_share_external均为false时,该参数只能为true | ||
| 475 | ban_share_external bool 是否允许企业外成员浏览文档 | ||
| 476 | enable_readonly_copy bool 仅浏览权限的成员是否允许导出、复制、打印 | ||
| 477 | watermark object 文档水印设置 | ||
| 478 | margin_type uint32 水印密度 1:稀疏 2:紧密 | ||
| 479 | show_visitor_name bool 是否展示访问者名字 | ||
| 480 | show_text bool 是否展示水印文字 | ||
| 481 | text bytes 水印文字 | ||
| 482 | doc_member_list obj[] 文档通知范围及权限列表 | ||
| 483 | type uint32 文档通知范围成员种类 1:user, 只支持成员 | ||
| 484 | userid bytes 企业成员的userid | ||
| 485 | tmp_external_userid string 外部用户临时id。同一个用户在不同的文档中返回的该id不一致。 | ||
| 486 | auth uint32 该文档通知范围成员的权限 1:只读 7:管理员 | ||
| 487 | co_auth_list object 文档查看权限特定部门列表,可以直接浏览文档 | ||
| 488 | type uint32 特定部门列表 2:部门, 目前只支持部门 | ||
| 489 | departmentid uint64 特定部门id | ||
| 490 | auth uint32 权限类型 1:只读, 目前只支持只读权限 | ||
| 491 | |||
| 492 | =cut | ||
| 493 | |||
| 494 | sub doc_get_auth { | ||
| 495 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 496 | my $access_token = $_[0]; | ||
| 497 | my $json = $_[1]; | ||
| 498 | my $ua = LWP::UserAgent->new; | ||
| 499 | $ua->timeout(30); | ||
| 500 | $ua->env_proxy; | ||
| 501 | |||
| 502 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/doc_get_auth?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 503 | if ($response->is_success) { | ||
| 504 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 505 | } | ||
| 506 | |||
| 507 | } | ||
| 508 | return 0; | ||
| 509 | } | ||
| 510 | |||
| 511 | =head2 mod_doc_join_rule(access_token, hash); | ||
| 512 | |||
| 513 | 修改文档查看规则 | ||
| 514 | 最后更新:2022/12/09 | ||
| 515 | |||
| 516 | =head2 SYNOPSIS | ||
| 517 | |||
| 518 | L<https://developer.work.weixin.qq.com/document/path/97778> | ||
| 519 | |||
| 520 | =head3 请求说明: | ||
| 521 | |||
| 522 | 该接口用于修改文档查看规则。 | ||
| 523 | |||
| 524 | =head4 请求包结构体为: | ||
| 525 | |||
| 526 | { | ||
| 527 | "docid":"DOCID", | ||
| 528 | "enable_corp_internal":true, | ||
| 529 | "corp_internal_auth":1, | ||
| 530 | "enable_corp_external":true, | ||
| 531 | "corp_external_auth":1, | ||
| 532 | "corp_internal_approve_only_by_admin":true, | ||
| 533 | "corp_external_approve_only_by_admin":true, | ||
| 534 | "ban_share_external":false, | ||
| 535 | "update_co_auth_list":true, | ||
| 536 | "co_auth_list":[ | ||
| 537 | { | ||
| 538 | "departmentid":DEPARTMENTID1, | ||
| 539 | "auth":1, | ||
| 540 | "type":2 | ||
| 541 | } | ||
| 542 | ] | ||
| 543 | } | ||
| 544 | |||
| 545 | =head4 参数说明: | ||
| 546 | |||
| 547 | 参数 类型 是否必须 说明 | ||
| 548 | access_token 是 调用接口凭证 | ||
| 549 | docid string 是 操作的docid | ||
| 550 | enable_corp_internal bool 否 是否允许企业内成员浏览文档, 有值则覆盖 | ||
| 551 | corp_internal_auth uint32 否 企业内成员主动查看文档后获得的权限类型 1:只读, 有值则覆盖 | ||
| 552 | enable_corp_external uint32 否 是否允许企业外成员浏览文档, 有值则覆盖 | ||
| 553 | corp_external_auth uint32 否 企业外成员主浏览文档后获得的权限类型 1:只读, 有值则覆盖 | ||
| 554 | corp_internal_approve_only_by_admin bool 否 企业内成员加入文档是否必须由管理员审批,enable_corp_internal为false时,只能为true,有值则覆盖。设置为true之前,文档需要有至少一个管理员。 | ||
| 555 | corp_external_approve_only_by_admin bool 否 企业外成员加入文档是否必须由管理员审批,enable_corp_external和ban_share_external均为false时,该参数只能为true,有值则覆盖。设置为true之前,文档需要有至少一个管理员。 | ||
| 556 | ban_share_external bool 否 是否允许企业外成员浏览, 有值则覆盖 | ||
| 557 | update_co_auth_list bool 否 是否更新文档查看权限的特定部门, true时更新特定部门列表 | ||
| 558 | co_auth_list object[] 否 需要更新文档查看权限特定部门时, 覆盖之前部门, 特别的: 列表为空则清空 | ||
| 559 | departmentid uint64 否 文档查看权限特定部门id | ||
| 560 | auth uint32 否 文档特定部门权限 1:只读, 目前只支持只读权限 | ||
| 561 | type uint32 否 文档特定部门类型 2:部门, 目前只支持部门 | ||
| 562 | |||
| 563 | =head4 权限说明: | ||
| 564 | |||
| 565 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 566 | 第三方应用需具有“文档”权限 | ||
| 567 | 代开发自建应用需具有“文档”权限 | ||
| 568 | 只能访问该应用创建的文档 | ||
| 569 | |||
| 570 | =head3 RETURN 返回结果: | ||
| 571 | |||
| 572 | { | ||
| 573 | "errcode": 0, | ||
| 574 | "errmsg": "ok" | ||
| 575 | } | ||
| 576 | |||
| 577 | =head4 RETURN 参数说明: | ||
| 578 | |||
| 579 | 参数 类型 说明 | ||
| 580 | errcode int32 错误码 | ||
| 581 | errmsg string 错误码说明 | ||
| 582 | |||
| 583 | =cut | ||
| 584 | |||
| 585 | sub mod_doc_join_rule { | ||
| 586 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 587 | my $access_token = $_[0]; | ||
| 588 | my $json = $_[1]; | ||
| 589 | my $ua = LWP::UserAgent->new; | ||
| 590 | $ua->timeout(30); | ||
| 591 | $ua->env_proxy; | ||
| 592 | |||
| 593 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/mod_doc_join_rule?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 594 | if ($response->is_success) { | ||
| 595 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 596 | } | ||
| 597 | |||
| 598 | } | ||
| 599 | return 0; | ||
| 600 | } | ||
| 601 | |||
| 602 | =head2 mod_doc_member(access_token, hash); | ||
| 603 | |||
| 604 | 修改文档通知范围及权限 | ||
| 605 | 最后更新:2023/02/22 | ||
| 606 | |||
| 607 | =head2 SYNOPSIS | ||
| 608 | |||
| 609 | L<https://developer.work.weixin.qq.com/document/path/97781> | ||
| 610 | |||
| 611 | =head3 请求说明: | ||
| 612 | |||
| 613 | 该接口用于修改文档通知范围列表,可以新增文档通知范围并设置权限、修改已有范围的权限以及删除文档通知范围内的人员 | ||
| 614 | |||
| 615 | =head4 请求包结构体为: | ||
| 616 | |||
| 617 | { | ||
| 618 | "docid":"DOCID", | ||
| 619 | "update_file_member_list":[ | ||
| 620 | { | ||
| 621 | "type":1, | ||
| 622 | "auth":7, | ||
| 623 | "userid":"USERID1" | ||
| 624 | } | ||
| 625 | ], | ||
| 626 | "del_file_member_list":[ | ||
| 627 | { | ||
| 628 | "type":1, | ||
| 629 | "userid":"USERID2" | ||
| 630 | }, | ||
| 631 | { | ||
| 632 | "type":1, | ||
| 633 | "tmp_external_userid":"TMP_EXTERNAL_USERID2" | ||
| 634 | } | ||
| 635 | ] | ||
| 636 | } | ||
| 637 | |||
| 638 | =head4 参数说明: | ||
| 639 | |||
| 640 | 参数 类型 是否必须 说明 | ||
| 641 | access_token 是 调用接口凭证 | ||
| 642 | docid string 是 操作的文档id | ||
| 643 | update_file_member_list obj[] 否 更新文档通知范围的列表, 批次大小最大100 | ||
| 644 | type uint32 是 文档通知范围的类型 1:用户。文档通知范围仅支持按人配置 | ||
| 645 | auth uint32 是 文档通知范围内人员获得的权限 1:只读权限, 7:管理员权限,文档管理员最多三个 | ||
| 646 | userid string 否 企业内成员的ID | ||
| 647 | tmp_external_userid string 否 外部用户临时id。同一个用户在不同的文档中返回的该id不一致。 | ||
| 648 | del_file_member_list obj[] 否 删除的文档通知范围列表,批次大小最大一百 | ||
| 649 | type uint32 是 文档通知范围的类型 1:用户。文档通知范围仅支持按人配置 | ||
| 650 | userid string 否 企业内成员的ID | ||
| 651 | tmp_external_userid string 否 外部用户临时id。同一个用户在不同的文档中返回的该id不一致。 | ||
| 652 | |||
| 653 | =head4 权限说明: | ||
| 654 | |||
| 655 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 656 | 第三方应用需具有“文档”权限 | ||
| 657 | 代开发自建应用需具有“文档”权限 | ||
| 658 | 只能访问该应用创建的文档 | ||
| 659 | |||
| 660 | =head3 RETURN 返回结果: | ||
| 661 | |||
| 662 | { | ||
| 663 | "errcode": 0, | ||
| 664 | "errmsg": "ok" | ||
| 665 | } | ||
| 666 | |||
| 667 | =head4 RETURN 参数说明: | ||
| 668 | |||
| 669 | 参数 类型 说明 | ||
| 670 | errcode int32 错误码 | ||
| 671 | errmsg string 错误码说明 | ||
| 672 | |||
| 673 | =cut | ||
| 674 | |||
| 675 | sub mod_doc_member { | ||
| 676 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 677 | my $access_token = $_[0]; | ||
| 678 | my $json = $_[1]; | ||
| 679 | my $ua = LWP::UserAgent->new; | ||
| 680 | $ua->timeout(30); | ||
| 681 | $ua->env_proxy; | ||
| 682 | |||
| 683 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/mod_doc_member?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 684 | if ($response->is_success) { | ||
| 685 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 686 | } | ||
| 687 | |||
| 688 | } | ||
| 689 | return 0; | ||
| 690 | } | ||
| 691 | |||
| 692 | =head2 mod_doc_safty_setting(access_token, hash); | ||
| 693 | |||
| 694 | 修改文档安全设置 | ||
| 695 | 最后更新:2022/12/09 | ||
| 696 | |||
| 697 | =head2 SYNOPSIS | ||
| 698 | |||
| 699 | L<https://developer.work.weixin.qq.com/document/path/97782> | ||
| 700 | |||
| 701 | =head3 请求说明: | ||
| 702 | |||
| 703 | 该接口用于修改文档的安全设置 | ||
| 704 | |||
| 705 | =head4 请求包结构体为: | ||
| 706 | |||
| 707 | { | ||
| 708 | "docid":"DOCID", | ||
| 709 | "enable_readonly_copy":false, | ||
| 710 | "watermark":{ | ||
| 711 | "margin_type":1, | ||
| 712 | "show_visitor_name":true, | ||
| 713 | "show_text":true, | ||
| 714 | "text":"test mark" | ||
| 715 | } | ||
| 716 | } | ||
| 717 | |||
| 718 | =head4 参数说明: | ||
| 719 | |||
| 720 | 参数 类型 是否必须 说明 | ||
| 721 | access_token 是 调用接口凭证 | ||
| 722 | docid string 是 操作的文档id | ||
| 723 | enable_readonly_copy bool 否 是否允许只读成员复制、下载文档,有值则覆盖 | ||
| 724 | watermark object 否 水印设置 | ||
| 725 | margin_type uint32 否 水印疏密度,1:稀疏,2:紧密 | ||
| 726 | show_visitor_name bool 否 是否展示访问者名字水印,有值则覆盖 | ||
| 727 | show_text bool 否 是否展示文本水印,有值则覆盖 | ||
| 728 | text string 否 文字水印的文字,有值则覆盖 | ||
| 729 | |||
| 730 | =head4 权限说明: | ||
| 731 | |||
| 732 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 733 | 第三方应用需具有“文档”权限 | ||
| 734 | 代开发自建应用需具有“文档”权限 | ||
| 735 | 只能访问该应用创建的文档 | ||
| 736 | |||
| 737 | =head3 RETURN 返回结果: | ||
| 738 | |||
| 739 | { | ||
| 740 | "errcode": 0, | ||
| 741 | "errmsg": "ok" | ||
| 742 | } | ||
| 743 | |||
| 744 | =head4 RETURN 参数说明: | ||
| 745 | |||
| 746 | 参数 类型 说明 | ||
| 747 | errcode int32 错误码 | ||
| 748 | errmsg string 错误码说明 | ||
| 749 | |||
| 750 | =cut | ||
| 751 | |||
| 752 | sub mod_doc_safty_setting { | ||
| 753 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 754 | my $access_token = $_[0]; | ||
| 755 | my $json = $_[1]; | ||
| 756 | my $ua = LWP::UserAgent->new; | ||
| 757 | $ua->timeout(30); | ||
| 758 | $ua->env_proxy; | ||
| 759 | |||
| 760 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/mod_doc_safty_setting?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 761 | if ($response->is_success) { | ||
| 762 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 763 | } | ||
| 764 | |||
| 765 | } | ||
| 766 | return 0; | ||
| 767 | } | ||
| 768 | |||
| 769 | =head1 FUNCTION | ||
| 770 | |||
| 771 | 管理收集表 | ||
| 772 | |||
| 773 | =head2 create_form(access_token, hash); | ||
| 774 | |||
| 775 | 创建收集表 | ||
| 776 | 最后更新:2023/07/12 | ||
| 777 | |||
| 778 | =head2 SYNOPSIS | ||
| 779 | |||
| 780 | L<https://developer.work.weixin.qq.com/document/path/97462> | ||
| 781 | |||
| 782 | =head3 请求说明: | ||
| 783 | |||
| 784 | 该接口用于创建收集表。 | ||
| 785 | |||
| 786 | =head4 请求包结构体为: | ||
| 787 | |||
| 788 | { | ||
| 789 | "spaceid": "SPACEID", | ||
| 790 | "fatherid": "FATHERID", | ||
| 791 | "form_info": { | ||
| 792 | "form_title": "FORM_TITLE", | ||
| 793 | "form_desc": "FORM_DESC", | ||
| 794 | "form_header": "FORM_HEADER", | ||
| 795 | "form_question": { | ||
| 796 | "items": [ | ||
| 797 | { | ||
| 798 | "question_id": 1, | ||
| 799 | "title": "TITLE", | ||
| 800 | "pos": 1, | ||
| 801 | "status": 1, | ||
| 802 | "reply_type": 1, | ||
| 803 | "must_reply": false, | ||
| 804 | "note": "NOTE", | ||
| 805 | "option_item": [ | ||
| 806 | { | ||
| 807 | "key": 1, | ||
| 808 | "value": "VALUE", | ||
| 809 | "status": 1 | ||
| 810 | } | ||
| 811 | ], | ||
| 812 | "placeholder": "PLACEHOLDER", | ||
| 813 | "question_extend_setting": {} | ||
| 814 | } | ||
| 815 | ] | ||
| 816 | }, | ||
| 817 | "form_setting": { | ||
| 818 | "fill_out_auth": 0, | ||
| 819 | "fill_in_range": { | ||
| 820 | "userids": [ | ||
| 821 | "USER_1", | ||
| 822 | "USER_2", | ||
| 823 | "USER_3" | ||
| 824 | ], | ||
| 825 | "departmentids": [ | ||
| 826 | 10001, | ||
| 827 | 10002, | ||
| 828 | 10003 | ||
| 829 | ] | ||
| 830 | }, | ||
| 831 | "setting_manager_range": { | ||
| 832 | "userids": [ | ||
| 833 | "USER_4", | ||
| 834 | "USER_5", | ||
| 835 | "USER_6" | ||
| 836 | ] | ||
| 837 | }, | ||
| 838 | "timed_repeat_info": { | ||
| 839 | "enable": false, | ||
| 840 | "week_flag": 0, | ||
| 841 | "remind_time": 0, | ||
| 842 | "repeat_type": 0, | ||
| 843 | "skip_holiday": false, | ||
| 844 | "day_of_month": 1, | ||
| 845 | "fork_finish_type": 0 | ||
| 846 | }, | ||
| 847 | "allow_multi_fill": false, | ||
| 848 | "timed_finish": 0, | ||
| 849 | "can_anonymous": false, | ||
| 850 | "can_notify_submit": false | ||
| 851 | } | ||
| 852 | } | ||
| 853 | } | ||
| 854 | |||
| 855 | =head4 参数说明: | ||
| 856 | |||
| 857 | 参数 类型 是否必须 说明 | ||
| 858 | access_token 是 调用接口凭证 | ||
| 859 | spaceid string 否 空间spaceid | ||
| 860 | fatherid string 否 父目录fileid, 在根目录时为空间spaceid | ||
| 861 | form_info obj 是 收集表信息 | ||
| 862 | form_title string 是 收集表标题 | ||
| 863 | form_desc string 否 收集表描述 | ||
| 864 | form_header string 否 收集表表头背景图链接 | ||
| 865 | form_question object 是 收集表的问题列表 | ||
| 866 | items object[] 是 问题数组 | ||
| 867 | question_id uint32 是 问题id,从1开始。如果是家校范围收集表,id从2开始。 | ||
| 868 | title string 是 问题描述 | ||
| 869 | pos uint32 是 问题序号,从1开始。 | ||
| 870 | status uint32 是 问题状态。1:正常;2:被删除 | ||
| 871 | reply_type uint32 是 问题类型。1:文本;2:单选;3:多选;5:位置;9:图片;10:文件;11:日期;14:时间;15:下拉列表;16:体温;17:签名;18:部门;19:成员 22:时长 | ||
| 872 | must_reply bool 是 是否必答 | ||
| 873 | note string 否 问题备注 | ||
| 874 | placeholder string 否 编辑提示 | ||
| 875 | question_extend_setting object 否 问题的额外设置。不同问题类型有相应的设置,详见question_extend_setting字段描述 | ||
| 876 | option_item object[] 是 单选或者多选题的选项列表 | ||
| 877 | key uint32 是 选项key(1,2,3...) | ||
| 878 | value string 是 选项内容 | ||
| 879 | status uint32 是 选项状态。1:正常;2:被删除 | ||
| 880 | form_setting object 否 收集表设置 | ||
| 881 | fill_out_auth uint32 否 填写权限。0:所有人;1:企业内指定人/部门;4:家校所有范围。默认为0,所有人可填写。 | ||
| 882 | fill_in_range object 否 指定的可填写的人/部门 | ||
| 883 | userids string[] 否 企业成员userid列表 | ||
| 884 | departmentids uint64[] 否 部门id列表 | ||
| 885 | setting_manager_range object 否 收集表管理员 | ||
| 886 | timed_repeat_info object 否 定时重复设置项 | ||
| 887 | timed_repeat_info.enable bool 否 是否开启定时重复 | ||
| 888 | timed_repeat_info.remind_time uint32 否 提醒时间,为第一次提醒的时间戳。重复提醒的时间根据timed_repeat_info的相关字段计算。 | ||
| 889 | 如remind_time设置为当天10:00的时间戳,同时repeated_type设置了每天重复,那么每天的10:00都会触发提醒。 | ||
| 890 | timed_repeat_info.repeat_type uint32 否 重复类型。0:每周;1:每天;2:每月 | ||
| 891 | timed_repeat_info.week_flag uint32 否 每周几重复,按bit组合,只能repeat_type = 0 时填写。 | ||
| 892 | bit 0: 周一; bit 1: 周二;bit 2: 周三;bit 3: 周四; bit 4: 周五;bit 5: 周六 bit 6: 周日。如1表示周一,2表示周二,4表示周三,96表示周六和周日 | ||
| 893 | timed_repeat_info.skip_holiday bool 否 自动跳过节假日,只能repeat_type = 1 时填写。 | ||
| 894 | timed_repeat_info.day_of_month uint32 否 每月的第几天(1 - 31),只能repeat_type = 2时填写 | ||
| 895 | timed_repeat_info.fork_finish_type uint32 否 是否允许补填。0:允许;1:仅当天;2:最后五天内;3:一个月内;4:下一次生成前 | ||
| 896 | allow_multi_fill bool 否 是否允许每人提交多份。默认false | ||
| 897 | timed_finish uint32 否 定时关闭。定时重复与定时结束互斥,若都填,优先定时重复 | ||
| 898 | can_anonymous bool 否 是否支持匿名填写。默认false | ||
| 899 | can_notify_submit bool 否 是否有回复时提醒。默认false | ||
| 900 | |||
| 901 | =head4 权限说明: | ||
| 902 | |||
| 903 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 904 | 第三方应用需具有“文档”权限 | ||
| 905 | 代开发自建应用需具有“文档”权限 | ||
| 906 | |||
| 907 | =head3 RETURN 返回结果: | ||
| 908 | |||
| 909 | { | ||
| 910 | "errcode": 0, | ||
| 911 | "errmsg": "ok", | ||
| 912 | "formid": "FORMID" | ||
| 913 | } | ||
| 914 | |||
| 915 | =head4 RETURN 参数说明: | ||
| 916 | |||
| 917 | 参数 类型 说明 | ||
| 918 | errcode int32 错误码 | ||
| 919 | errmsg string 错误码说明 | ||
| 920 | formid string 收集表id | ||
| 921 | |||
| 922 | =head4 question_extend_setting字段描述 | ||
| 923 | |||
| 924 | L<https://developer.work.weixin.qq.com/document/path/97462#question-extend-setting字段描述> | ||
| 925 | |||
| 926 | =cut | ||
| 927 | |||
| 928 | sub create_form { | ||
| 929 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 930 | my $access_token = $_[0]; | ||
| 931 | my $json = $_[1]; | ||
| 932 | my $ua = LWP::UserAgent->new; | ||
| 933 | $ua->timeout(30); | ||
| 934 | $ua->env_proxy; | ||
| 935 | |||
| 936 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/create_form?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 937 | if ($response->is_success) { | ||
| 938 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 939 | } | ||
| 940 | |||
| 941 | } | ||
| 942 | return 0; | ||
| 943 | } | ||
| 944 | |||
| 945 | =head2 modify_form(access_token, hash); | ||
| 946 | |||
| 947 | 编辑收集表 | ||
| 948 | 最后更新:2023/06/13 | ||
| 949 | |||
| 950 | =head2 SYNOPSIS | ||
| 951 | |||
| 952 | L<https://developer.work.weixin.qq.com/document/path/97816> | ||
| 953 | |||
| 954 | =head3 请求说明: | ||
| 955 | |||
| 956 | 该接口用于编辑收集表。 | ||
| 957 | |||
| 958 | =head4 请求包结构体为: | ||
| 959 | |||
| 960 | { | ||
| 961 | "oper": 1, | ||
| 962 | "formid": "FORMID", | ||
| 963 | "form_info": { | ||
| 964 | "form_title": "FORM_TITLE", | ||
| 965 | "form_desc": "FORM_DESC", | ||
| 966 | "form_header": "FORM_HEADER", | ||
| 967 | "form_question": { | ||
| 968 | "items": [ | ||
| 969 | { | ||
| 970 | "question_id": 1, | ||
| 971 | "title": "TITLE", | ||
| 972 | "pos": 1, | ||
| 973 | "status": 1, | ||
| 974 | "reply_type": 1, | ||
| 975 | "must_reply": false, | ||
| 976 | "note": "NOTE", | ||
| 977 | "option_item": [ | ||
| 978 | { | ||
| 979 | "key": 1, | ||
| 980 | "value": "VALUE", | ||
| 981 | "status": 1 | ||
| 982 | } | ||
| 983 | ], | ||
| 984 | "placeholder": "PLACEHOLDER", | ||
| 985 | "question_extend_setting": {} | ||
| 986 | } | ||
| 987 | ] | ||
| 988 | }, | ||
| 989 | "form_setting": { | ||
| 990 | "fill_out_auth": 0, | ||
| 991 | "fill_in_range": { | ||
| 992 | "userids": [ | ||
| 993 | "USER_1", | ||
| 994 | "USER_2", | ||
| 995 | "USER_3" | ||
| 996 | ], | ||
| 997 | "departmentids": [ | ||
| 998 | 10001, | ||
| 999 | 10002, | ||
| 1000 | 10003 | ||
| 1001 | ] | ||
| 1002 | }, | ||
| 1003 | "setting_manager_range": { | ||
| 1004 | "userids": [ | ||
| 1005 | "USER_4", | ||
| 1006 | "USER_5", | ||
| 1007 | "USER_6" | ||
| 1008 | ] | ||
| 1009 | }, | ||
| 1010 | "timed_repeat_info": { | ||
| 1011 | "enable": false, | ||
| 1012 | "week_flag": 0, | ||
| 1013 | "remind_time": 0, | ||
| 1014 | "repeat_type": 0, | ||
| 1015 | "skip_holiday": false, | ||
| 1016 | "day_of_month": 1, | ||
| 1017 | "fork_finish_type": 0 | ||
| 1018 | }, | ||
| 1019 | "allow_multi_fill": false, | ||
| 1020 | "timed_finish": 0, | ||
| 1021 | "can_anonymous": false, | ||
| 1022 | "can_notify_submit": false | ||
| 1023 | } | ||
| 1024 | } | ||
| 1025 | } | ||
| 1026 | |||
| 1027 | =head4 参数说明: | ||
| 1028 | |||
| 1029 | 参数 类型 是否必须 说明 | ||
| 1030 | access_token 是 调用接口凭证 | ||
| 1031 | oper uint32 是 操作类型。1:全量修改问题;2:全量修改设置 | ||
| 1032 | formid string 是 收集表id | ||
| 1033 | form_title string 否 收集表标题(操作1修改) | ||
| 1034 | form_desc string 否 收集表描述(操作1修改) | ||
| 1035 | form_header string 否 收集表表头背景图链接(操作1修改) | ||
| 1036 | form_question object 否 收集表的问题列表(操作1修改) | ||
| 1037 | items object[] 是 问题数组 | ||
| 1038 | question_id uint32 是 问题id,从1开始。如果是家校范围收集表,id从2开始。 | ||
| 1039 | title string 是 问题描述 | ||
| 1040 | pos uint32 是 问题序号,从1开始。 | ||
| 1041 | status uint32 是 问题状态。1:正常;2:被删除 | ||
| 1042 | reply_type uint32 是 问题类型。1:文本;2:单选;3:多选;5:位置;9:图片;10:文件;11:日期;14:时间;15:下拉列表;16:体温;17:签名;18:部门;19:成员 22:时长 | ||
| 1043 | must_reply bool 是 是否必答 | ||
| 1044 | note string 否 问题备注 | ||
| 1045 | placeholder string 否 编辑提示 | ||
| 1046 | question_extend_setting object 否 问题的额外设置。不同问题类型有相应的设置,详见question_extend_setting字段描述 | ||
| 1047 | option_item object[] 是 单选或者多选题的选项列表 | ||
| 1048 | key uint32 是 选项key(1,2,3...) | ||
| 1049 | value string 是 选项内容 | ||
| 1050 | status uint32 是 选项状态。1:正常;2:被删除 | ||
| 1051 | form_setting object 否 收集表设置(操作2修改) | ||
| 1052 | fill_out_auth uint32 是 填写权限。0:所有人;1:企业内指定人/部门。若收集表当前为家校范围,则无法修改。 | ||
| 1053 | fill_in_range object 否 指定的可填写的人/部门 | ||
| 1054 | userids string[] 否 企业成员userid列表 | ||
| 1055 | departmentids uint64[] 否 部门id列表 | ||
| 1056 | setting_manager_range object 否 收集表管理员 | ||
| 1057 | timed_repeat_info object 否 定时重复设置项 | ||
| 1058 | timed_repeat_info.enable bool 否 是否开启定时重复 | ||
| 1059 | timed_repeat_info.remind_time uint32 否 提醒时间 | ||
| 1060 | timed_repeat_info.repeat_type uint32 否 重复类型。0:每周;1:每天;2:每月 | ||
| 1061 | timed_repeat_info.week_flag uint32 否 每周几重复,只能repeat_type = 0 时填写。1:星期一;2:星期二;4:星期三;8:星期四;16:星期五;32:星期六;64:星期日 | ||
| 1062 | timed_repeat_info.skip_holiday bool 否 自动跳过节假日,只能repeat_type = 1 时填写。 | ||
| 1063 | timed_repeat_info.day_of_month uint32 否 每月的第几天(1 - 31),只能repeat_type = 2时填写 | ||
| 1064 | timed_repeat_info.fork_finish_type uint32 否 是否允许补填。0:允许;1:仅当天;2:最后五天内;3:一个月内;4:下一次生成前 | ||
| 1065 | allow_multi_fill bool 否 是否允许每人提交多份。默认false | ||
| 1066 | timed_finish uint32 否 定时关闭。定时重复与定时结束互斥,若都填,优先定时重复 | ||
| 1067 | can_anonymous bool 否 是否支持匿名填写。默认false | ||
| 1068 | can_notify_submit bool 否 是否有回复时提醒。默认false | ||
| 1069 | |||
| 1070 | =head4 权限说明: | ||
| 1071 | |||
| 1072 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 1073 | 第三方应用需具有“文档”权限 | ||
| 1074 | 代开发自建应用需具有“文档”权限 | ||
| 1075 | |||
| 1076 | =head3 RETURN 返回结果: | ||
| 1077 | |||
| 1078 | { | ||
| 1079 | "errcode": 0, | ||
| 1080 | "errmsg": "ok" | ||
| 1081 | } | ||
| 1082 | |||
| 1083 | =head4 RETURN 参数说明: | ||
| 1084 | |||
| 1085 | 参数 类型 说明 | ||
| 1086 | errcode int32 错误码 | ||
| 1087 | errmsg string 错误码说明 | ||
| 1088 | |||
| 1089 | =cut | ||
| 1090 | |||
| 1091 | sub modify_form { | ||
| 1092 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 1093 | my $access_token = $_[0]; | ||
| 1094 | my $json = $_[1]; | ||
| 1095 | my $ua = LWP::UserAgent->new; | ||
| 1096 | $ua->timeout(30); | ||
| 1097 | $ua->env_proxy; | ||
| 1098 | |||
| 1099 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/modify_form?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 1100 | if ($response->is_success) { | ||
| 1101 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 1102 | } | ||
| 1103 | |||
| 1104 | } | ||
| 1105 | return 0; | ||
| 1106 | } | ||
| 1107 | |||
| 1108 | =head2 get_form_info(access_token, hash); | ||
| 1109 | |||
| 1110 | 获取收集表信息 | ||
| 1111 | 最后更新:2023/03/15 | ||
| 1112 | |||
| 1113 | =head2 SYNOPSIS | ||
| 1114 | |||
| 1115 | L<https://developer.work.weixin.qq.com/document/path/97817> | ||
| 1116 | |||
| 1117 | =head3 请求说明: | ||
| 1118 | |||
| 1119 | 该接口用于读取收集表的信息 | ||
| 1120 | |||
| 1121 | =head4 请求包结构体为: | ||
| 1122 | |||
| 1123 | { | ||
| 1124 | "formid":"FORMID" | ||
| 1125 | } | ||
| 1126 | |||
| 1127 | =head4 参数说明: | ||
| 1128 | |||
| 1129 | 参数 类型 是否必须 说明 | ||
| 1130 | access_token 是 调用接口凭证 | ||
| 1131 | formid string 是 操作的收集表ID | ||
| 1132 | |||
| 1133 | =head4 权限说明: | ||
| 1134 | |||
| 1135 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 1136 | 第三方应用需具有“文档”权限 | ||
| 1137 | 代开发自建应用需具有“文档”权限 | ||
| 1138 | 只能操作该应用创建的文档 | ||
| 1139 | |||
| 1140 | =head3 RETURN 返回结果: | ||
| 1141 | |||
| 1142 | { | ||
| 1143 | "errcode":0, | ||
| 1144 | "errmsg":"ok", | ||
| 1145 | "form_info":{ | ||
| 1146 | "formid":"FORMID1", | ||
| 1147 | "form_title":"api创建的收集表_周期", | ||
| 1148 | "form_desc":"这是描述", | ||
| 1149 | "form_header":"URL", | ||
| 1150 | "form_question":{ | ||
| 1151 | "items":[ | ||
| 1152 | { | ||
| 1153 | "question_id":1, | ||
| 1154 | "title":"问题1", | ||
| 1155 | "pos":1, | ||
| 1156 | "status":1, | ||
| 1157 | "reply_type":1, | ||
| 1158 | "must_reply":true, | ||
| 1159 | "note":"问题备注1", | ||
| 1160 | "placeholder":"提示1" | ||
| 1161 | }, | ||
| 1162 | { | ||
| 1163 | "question_id":2, | ||
| 1164 | "title":"问题2", | ||
| 1165 | "pos":2, | ||
| 1166 | "status":1, | ||
| 1167 | "reply_type":2, | ||
| 1168 | "must_reply":false, | ||
| 1169 | "note":"问题备注2", | ||
| 1170 | "option_item":[ | ||
| 1171 | { | ||
| 1172 | "key":1, | ||
| 1173 | "value":"A", | ||
| 1174 | "status":1 | ||
| 1175 | }, | ||
| 1176 | { | ||
| 1177 | "key":2, | ||
| 1178 | "value":"B", | ||
| 1179 | "status":1 | ||
| 1180 | }, | ||
| 1181 | { | ||
| 1182 | "key":3, | ||
| 1183 | "value":"C", | ||
| 1184 | "status":1 | ||
| 1185 | } | ||
| 1186 | ], | ||
| 1187 | "placeholder":"提示2" | ||
| 1188 | } | ||
| 1189 | ] | ||
| 1190 | }, | ||
| 1191 | "form_setting":{ | ||
| 1192 | "fill_out_auth":1, | ||
| 1193 | "fill_in_range":{ | ||
| 1194 | "departmentids":[ | ||
| 1195 | 1 | ||
| 1196 | ], | ||
| 1197 | "userids": [ | ||
| 1198 | "USERID1", | ||
| 1199 | "USERID2" | ||
| 1200 | }, | ||
| 1201 | "setting_manager_range":{ | ||
| 1202 | "userids":[ | ||
| 1203 | "USERID1", | ||
| 1204 | "USERID2" | ||
| 1205 | ] | ||
| 1206 | }, | ||
| 1207 | "timed_repeat_info":{ | ||
| 1208 | "enable":true, | ||
| 1209 | "remind_time":1668389400, | ||
| 1210 | "rule_ctime":1668418140, | ||
| 1211 | "rule_mtime":1668418140, | ||
| 1212 | "repeat_type":1, | ||
| 1213 | "skip_holiday":false | ||
| 1214 | }, | ||
| 1215 | "allow_multi_fill":false, | ||
| 1216 | "timed_finish":0, | ||
| 1217 | "can_anonymous":false, | ||
| 1218 | "can_notify_submit":true | ||
| 1219 | }, | ||
| 1220 | "repeated_id":[ | ||
| 1221 | "REPEAT_ID1" | ||
| 1222 | ] | ||
| 1223 | } | ||
| 1224 | } | ||
| 1225 | |||
| 1226 | =head4 RETURN 参数说明: | ||
| 1227 | |||
| 1228 | 参数 类型 说明 | ||
| 1229 | errcode int32 错误码 | ||
| 1230 | errmsg string 错误码说明 | ||
| 1231 | form_info object 收集表信息 | ||
| 1232 | formid string 收集表id | ||
| 1233 | form_title string 收集表标题 | ||
| 1234 | form_desc string 收集表描述 | ||
| 1235 | form_header string 收集表表头背景图链接 | ||
| 1236 | form_question object 收集表的问题列表 | ||
| 1237 | form_setting object 收集表的设置 | ||
| 1238 | repeated_id string[] 收集表的周期id,用于获取答案列表和具体的回答 | ||
| 1239 | |||
| 1240 | =cut | ||
| 1241 | |||
| 1242 | sub get_form_info { | ||
| 1243 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 1244 | my $access_token = $_[0]; | ||
| 1245 | my $json = $_[1]; | ||
| 1246 | my $ua = LWP::UserAgent->new; | ||
| 1247 | $ua->timeout(30); | ||
| 1248 | $ua->env_proxy; | ||
| 1249 | |||
| 1250 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/get_form_info?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 1251 | if ($response->is_success) { | ||
| 1252 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 1253 | } | ||
| 1254 | |||
| 1255 | } | ||
| 1256 | return 0; | ||
| 1257 | } | ||
| 1258 | |||
| 1259 | =head2 get_form_statistic(access_token, hash); | ||
| 1260 | |||
| 1261 | 收集表的统计信息查询 | ||
| 1262 | 最后更新:2023/03/07 | ||
| 1263 | |||
| 1264 | =head2 SYNOPSIS | ||
| 1265 | |||
| 1266 | L<https://developer.work.weixin.qq.com/document/path/97818> | ||
| 1267 | |||
| 1268 | =head3 请求说明: | ||
| 1269 | |||
| 1270 | 该接口用于获取收集表的统计信息、已回答成员列表和未回答成员列表 | ||
| 1271 | |||
| 1272 | =head4 请求包结构体为: | ||
| 1273 | |||
| 1274 | // 仅获取统计结果 | ||
| 1275 | { | ||
| 1276 | "repeated_id":"REPEATED_ID1", | ||
| 1277 | "req_type":1 | ||
| 1278 | } | ||
| 1279 | // 获取已提交的列表 | ||
| 1280 | { | ||
| 1281 | "repeated_id":"REPEATED_ID2", | ||
| 1282 | "req_type":2, | ||
| 1283 | "start_time":1667395287, | ||
| 1284 | "end_time":1668418369, | ||
| 1285 | "limit":20, | ||
| 1286 | "cursor":1 | ||
| 1287 | } | ||
| 1288 | // 获取未提交的列表 | ||
| 1289 | { | ||
| 1290 | "repeated_id":"REPEATED_ID3", | ||
| 1291 | "req_type":3, | ||
| 1292 | "limit":20, | ||
| 1293 | "cursor":1 | ||
| 1294 | } | ||
| 1295 | |||
| 1296 | =head4 参数说明: | ||
| 1297 | |||
| 1298 | 参数 类型 是否必须 说明 | ||
| 1299 | access_token 是 调用接口凭证 | ||
| 1300 | repeated_id string 是 操作的收集表的repeated_id,来源于get_form_info的返回 | ||
| 1301 | req_type uint32 是 请求类型 1:只获取统计结果 2:获取已提交列表 3:获取未提交列表 | ||
| 1302 | start_time uint64 否 拉取已提交列表时必填,其余type不填。筛选开始时间,以当天的00:00:00开始筛选 | ||
| 1303 | end_time uint64 否 拉取已提交列表时必填,其余type不填。筛选结束时间,以当天的23:59:59结束筛选 | ||
| 1304 | limit uint64 否 分页拉取时批次大小,最大10000 | ||
| 1305 | cursor uint64 否 分页拉取的游标,首次不传 | ||
| 1306 | |||
| 1307 | =head4 权限说明: | ||
| 1308 | |||
| 1309 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 1310 | 第三方应用需具有“文档”权限 | ||
| 1311 | 代开发自建应用需具有“文档”权限 | ||
| 1312 | 只能操作该应用创建的文档 | ||
| 1313 | |||
| 1314 | =head3 RETURN 返回结果: | ||
| 1315 | |||
| 1316 | // req_type = 1 仅获取统计信息 | ||
| 1317 | { | ||
| 1318 | "errcode":0, | ||
| 1319 | "errmsg":"ok", | ||
| 1320 | "fill_cnt":1, | ||
| 1321 | "fill_user_cnt":1, | ||
| 1322 | "unfill_user_cnt":90 | ||
| 1323 | } | ||
| 1324 | // req_type = 2,获取已提交列表 | ||
| 1325 | { | ||
| 1326 | "errcode":0, | ||
| 1327 | "errmsg":"ok", | ||
| 1328 | "fill_cnt":1, | ||
| 1329 | "fill_user_cnt":1, | ||
| 1330 | "unfill_user_cnt":90, | ||
| 1331 | "submit_users":[ | ||
| 1332 | { | ||
| 1333 | "userid":"USERID1", | ||
| 1334 | "submit_time":1668418200, | ||
| 1335 | "answer_id":1, | ||
| 1336 | "user_name":"USER_NAME1" | ||
| 1337 | }, | ||
| 1338 | { | ||
| 1339 | "tmp_external_userid":"TMP_EXTERNAL_USERID1", | ||
| 1340 | "submit_time":1668418200, | ||
| 1341 | "answer_id":2, | ||
| 1342 | "user_name":"USER_NAME2" | ||
| 1343 | } | ||
| 1344 | ], | ||
| 1345 | "has_more":false, | ||
| 1346 | "cursor":1 | ||
| 1347 | } | ||
| 1348 | // req_type = 3,获取未提交列表,仅当限制提交范围时有结果 | ||
| 1349 | { | ||
| 1350 | "errcode":0, | ||
| 1351 | "errmsg":"ok", | ||
| 1352 | "fill_cnt":1, | ||
| 1353 | "fill_user_cnt":1, | ||
| 1354 | "unfill_user_cnt":90, | ||
| 1355 | "unfill_users":[ | ||
| 1356 | { | ||
| 1357 | "userid":"USERID1", | ||
| 1358 | "user_name":"USER_NAME1" | ||
| 1359 | } | ||
| 1360 | ], | ||
| 1361 | "has_more":false, | ||
| 1362 | "cursor":1 | ||
| 1363 | } | ||
| 1364 | |||
| 1365 | =head4 RETURN 参数说明: | ||
| 1366 | |||
| 1367 | 参数 类型 说明 | ||
| 1368 | errcode int32 错误码 | ||
| 1369 | errmsg string 错误码说明 | ||
| 1370 | fill_cnt uint64 已填写次数 | ||
| 1371 | fill_user_cnt uint64 已填写人数 | ||
| 1372 | unfill_user_cnt uint64 未填写人数 | ||
| 1373 | submit_users object[] 已填写人列表 | ||
| 1374 | tmp_external_userid string 外部用户临时id,匿名填写不返回,同一个用户在不同的收集表中返回的该id不一致。 | ||
| 1375 | 可进一步通过tmp_external_userid的转换接口转换成external_userid,方便识别外部填写人的身份。 | ||
| 1376 | userid string 企业内成员的id,匿名填写不返回 | ||
| 1377 | submit_time uint64 提交时间 | ||
| 1378 | answer_id uint64 答案id | ||
| 1379 | user_name string 名字,匿名填写不返回 | ||
| 1380 | userid string 企业内成员的id,匿名填写不返回 | ||
| 1381 | unfill_users object[] 未填写人列表 | ||
| 1382 | user_name string 名字 | ||
| 1383 | userid string 企业内成员的id | ||
| 1384 | has_more bool 是否还有更多 | ||
| 1385 | cursor uint64 上次分页拉取返回的cursor | ||
| 1386 | |||
| 1387 | =cut | ||
| 1388 | |||
| 1389 | sub get_form_statistic { | ||
| 1390 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 1391 | my $access_token = $_[0]; | ||
| 1392 | my $json = $_[1]; | ||
| 1393 | my $ua = LWP::UserAgent->new; | ||
| 1394 | $ua->timeout(30); | ||
| 1395 | $ua->env_proxy; | ||
| 1396 | |||
| 1397 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/get_form_statistic?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 1398 | if ($response->is_success) { | ||
| 1399 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 1400 | } | ||
| 1401 | |||
| 1402 | } | ||
| 1403 | return 0; | ||
| 1404 | } | ||
| 1405 | |||
| 1406 | =head2 get_form_answer(access_token, hash); | ||
| 1407 | |||
| 1408 | 读取收集表答案 | ||
| 1409 | 最后更新:2023/07/12 | ||
| 1410 | |||
| 1411 | =head2 SYNOPSIS | ||
| 1412 | |||
| 1413 | L<https://developer.work.weixin.qq.com/document/path/97819> | ||
| 1414 | |||
| 1415 | =head3 请求说明: | ||
| 1416 | |||
| 1417 | 该接口用于读取收集表的答案 | ||
| 1418 | |||
| 1419 | =head4 请求包结构体为: | ||
| 1420 | |||
| 1421 | { | ||
| 1422 | "repeated_id":"REPEATED_ID1", | ||
| 1423 | "answer_ids":[ | ||
| 1424 | 1 | ||
| 1425 | ] | ||
| 1426 | } | ||
| 1427 | |||
| 1428 | =head4 参数说明: | ||
| 1429 | |||
| 1430 | 参数 类型 是否必须 说明 | ||
| 1431 | access_token 是 调用接口凭证 | ||
| 1432 | repeated_id string 是 操作的收集表周期id | ||
| 1433 | answer_ids uint64[] 是 需要拉取的答案列表,批次大小最大100 | ||
| 1434 | |||
| 1435 | =head4 权限说明: | ||
| 1436 | |||
| 1437 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 1438 | 第三方应用需具有“文档”权限 | ||
| 1439 | 代开发自建应用需具有“文档”权限 | ||
| 1440 | 只能操作该应用创建的文档 | ||
| 1441 | |||
| 1442 | =head3 RETURN 返回结果: | ||
| 1443 | |||
| 1444 | { | ||
| 1445 | "errcode": 0, | ||
| 1446 | "errmsg": "ok", | ||
| 1447 | "answer": { | ||
| 1448 | "answer_list": [ | ||
| 1449 | { | ||
| 1450 | "answer_id": 15, | ||
| 1451 | "user_name": "USER_NAME1", | ||
| 1452 | "ctime": 1668430580, | ||
| 1453 | "mtime": 1668430580, | ||
| 1454 | "reply": { | ||
| 1455 | "items": [ | ||
| 1456 | { | ||
| 1457 | "question_id": 1, | ||
| 1458 | "text_reply": "Ndjnd" | ||
| 1459 | }, | ||
| 1460 | { | ||
| 1461 | "question_id": 2, | ||
| 1462 | "option_reply": [ | ||
| 1463 | 2 | ||
| 1464 | ] | ||
| 1465 | }, | ||
| 1466 | { | ||
| 1467 | "question_id": 3, | ||
| 1468 | "text_reply": "20:53" | ||
| 1469 | }, | ||
| 1470 | { | ||
| 1471 | "question_id": 4, | ||
| 1472 | "text_reply": "73℃" | ||
| 1473 | }, | ||
| 1474 | { | ||
| 1475 | "question_id": 5, | ||
| 1476 | "file_extend_reply": [ | ||
| 1477 | { | ||
| 1478 | "name": "FILE_NAME1", | ||
| 1479 | "fileid": "FILEID1" | ||
| 1480 | } | ||
| 1481 | ] | ||
| 1482 | }, | ||
| 1483 | { | ||
| 1484 | "question_id": 6, | ||
| 1485 | "text_reply": "四川省/成都市/武侯区/天府三街(峰汇中心)" | ||
| 1486 | }, | ||
| 1487 | { | ||
| 1488 | "question_id": 7, | ||
| 1489 | "text_reply": "test" | ||
| 1490 | }, | ||
| 1491 | { | ||
| 1492 | "question_id": 8, | ||
| 1493 | "option_reply": [ | ||
| 1494 | 1 | ||
| 1495 | ] | ||
| 1496 | }, | ||
| 1497 | { | ||
| 1498 | "question_id": 9, | ||
| 1499 | "text_reply": "2022年11月" | ||
| 1500 | }, | ||
| 1501 | { | ||
| 1502 | "question_id": 10, | ||
| 1503 | "option_reply": [ | ||
| 1504 | 5 | ||
| 1505 | ] | ||
| 1506 | }, | ||
| 1507 | { | ||
| 1508 | "question_id": 11, | ||
| 1509 | "option_reply": [ | ||
| 1510 | 3 | ||
| 1511 | ], | ||
| 1512 | "option_extend_reply": [ | ||
| 1513 | { | ||
| 1514 | "option_reply": 3, | ||
| 1515 | "extend_text": "test" | ||
| 1516 | } | ||
| 1517 | ] | ||
| 1518 | }, | ||
| 1519 | { | ||
| 1520 | "question_id": 12, | ||
| 1521 | "department_reply": { | ||
| 1522 | "list": [ | ||
| 1523 | { | ||
| 1524 | "department_id": 3 | ||
| 1525 | } | ||
| 1526 | ] | ||
| 1527 | } | ||
| 1528 | }, | ||
| 1529 | { | ||
| 1530 | "question_id": 13, | ||
| 1531 | "member_reply": { | ||
| 1532 | "list": [ | ||
| 1533 | { | ||
| 1534 | "userid": "zhangsan" | ||
| 1535 | } | ||
| 1536 | ] | ||
| 1537 | } | ||
| 1538 | }, | ||
| 1539 | { | ||
| 1540 | "question_id": 14, | ||
| 1541 | "duration_reply": { | ||
| 1542 | "begin_time": 1586136317, | ||
| 1543 | "end_time": 1586236317, | ||
| 1544 | "time_scale": 0, | ||
| 1545 | "day_range": 0, | ||
| 1546 | "days": 1.0, | ||
| 1547 | "hours": 2.5 | ||
| 1548 | } | ||
| 1549 | } | ||
| 1550 | ] | ||
| 1551 | }, | ||
| 1552 | "answer_status": 1, | ||
| 1553 | "tmp_external_userid": "TMP_EXTERNAL_USERID1" | ||
| 1554 | } | ||
| 1555 | ] | ||
| 1556 | } | ||
| 1557 | } | ||
| 1558 | |||
| 1559 | =head4 RETURN 参数说明: | ||
| 1560 | |||
| 1561 | 参数 类型 说明 | ||
| 1562 | errcode int32 错误码 | ||
| 1563 | errmsg string 错误码说明 | ||
| 1564 | answer object 答案 | ||
| 1565 | answer_list object[] 答案列表 | ||
| 1566 | answer_id uint64 答案id | ||
| 1567 | user_name string 用户名 | ||
| 1568 | ctime uint64 创建时间 | ||
| 1569 | mtime uint64 修改时间 | ||
| 1570 | reply object 该用户的答案明细 | ||
| 1571 | items object[] 每个问题的答案 | ||
| 1572 | question_id uint64 问题id | ||
| 1573 | text_reply string 答案 | ||
| 1574 | option_reply uint32[] 选择题答案,多选题有多个答案 | ||
| 1575 | option_extend_reply object[] 选择题,其他选项列表 | ||
| 1576 | option_extend_reply.option_reply uint32 其他选项的答案id | ||
| 1577 | option_extend_reply.extend_text string 其他选项的答案字符串 | ||
| 1578 | file_extend_reply object[] 文件题答案列表 | ||
| 1579 | file_extend_reply.name string 文件题答案的文件名 | ||
| 1580 | file_extend_reply.fileid string 文件题答案的文件id | ||
| 1581 | department_reply object 部门题答案 | ||
| 1582 | department_reply.list object[] 部门题选择的部门列表 | ||
| 1583 | department_reply.list[].department_id object[] 部门id | ||
| 1584 | member_reply object 成员题答案 | ||
| 1585 | member_reply.list object[] 成员选择的成员列表 | ||
| 1586 | member_reply.list[].userid object[] 成员id | ||
| 1587 | duration_reply object 时长题答案 | ||
| 1588 | duration_reply.begin_time uint32 开始时间,时间戳 | ||
| 1589 | duration_reply.end_time uint32 结束时间,时间戳 | ||
| 1590 | duration_reply.time_scale uint32 时间刻度。1: 按天 2: 按小时 | ||
| 1591 | duration_reply.day_range uint32 单位换算,多少小时/天。time_scale为2返回 | ||
| 1592 | duration_reply.days float 天数。time_scale为1返回 | ||
| 1593 | duration_reply.hours float 小时数。time_scale为2返回 | ||
| 1594 | answer_status uint32 答案状态 1:正常 3:统计者移除此答案或删除 | ||
| 1595 | tmp_external_userid string 外部用户临时id,匿名填写不返回,同一个用户在不同的收集表中返回的该id不一致。 | ||
| 1596 | 可进一步通过tmp_external_userid的转换接口转换成外部联系人的external_userid,方便识别外部填写人的身份。 | ||
| 1597 | userid string 用户id,匿名填写不返回 | ||
| 1598 | |||
| 1599 | =cut | ||
| 1600 | |||
| 1601 | sub get_form_answer { | ||
| 1602 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 1603 | my $access_token = $_[0]; | ||
| 1604 | my $json = $_[1]; | ||
| 1605 | my $ua = LWP::UserAgent->new; | ||
| 1606 | $ua->timeout(30); | ||
| 1607 | $ua->env_proxy; | ||
| 1608 | |||
| 1609 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/get_form_answer?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 1610 | if ($response->is_success) { | ||
| 1611 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 1612 | } | ||
| 1613 | |||
| 1614 | } | ||
| 1615 | return 0; | ||
| 1616 | } | ||
| 1617 | |||
| 1618 | =head2 file_acl_del(access_token, hash); | ||
| 1619 | |||
| 1620 | 删除指定人 | ||
| 1621 | |||
| 1622 | =head2 SYNOPSIS | ||
| 1623 | |||
| 1624 | L<https://developer.work.weixin.qq.com/document/path/93658#删除指定人> | ||
| 1625 | |||
| 1626 | =head3 请求说明: | ||
| 1627 | |||
| 1628 | 该接口用于删除指定文件的指定人/部门。 | ||
| 1629 | |||
| 1630 | =head4 请求包结构体为: | ||
| 1631 | |||
| 1632 | { | ||
| 1633 | "userid": "USERID", | ||
| 1634 | "fileid": "FILEID", | ||
| 1635 | "auth_info": [{ | ||
| 1636 | "type": 1, | ||
| 1637 | "userid": "USERID1" | ||
| 1638 | }, { | ||
| 1639 | "type": 2, | ||
| 1640 | "departmentid": DEPARTMENT_ID1 | ||
| 1641 | }] | ||
| 1642 | } | ||
| 1643 | |||
| 1644 | =head4 参数说明: | ||
| 1645 | |||
| 1646 | 参数 类型 是否必须 说明 | ||
| 1647 | userid string 是 操作者userid | ||
| 1648 | fileid string 是 文件fileid | ||
| 1649 | auth_info obj[] 是 被移除的成员信息 | ||
| 1650 | type uint32 是 成员类型 1:个人 2:部门 | ||
| 1651 | userid string 是 成员userid,字符串 (type为1时填写) | ||
| 1652 | departmentid uint32 是 部门departmentid, 32位整型范围是[0, 2^32) (type为2时填写) | ||
| 1653 | |||
| 1654 | =head4 权限说明: | ||
| 1655 | |||
| 1656 | =head3 RETURN 返回结果: | ||
| 1657 | |||
| 1658 | { | ||
| 1659 | "errcode": 0, | ||
| 1660 | "errmsg": "ok" | ||
| 1661 | } | ||
| 1662 | |||
| 1663 | =head4 RETURN 参数说明: | ||
| 1664 | |||
| 1665 | 参数 类型 说明 | ||
| 1666 | errcode int32 错误码 | ||
| 1667 | errmsg string 错误码说明 | ||
| 1668 | |||
| 1669 | =cut | ||
| 1670 | |||
| 1671 | sub file_acl_del { | ||
| 1672 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 1673 | my $access_token = $_[0]; | ||
| 1674 | my $json = $_[1]; | ||
| 1675 | my $ua = LWP::UserAgent->new; | ||
| 1676 | $ua->timeout(30); | ||
| 1677 | $ua->env_proxy; | ||
| 1678 | |||
| 1679 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_acl_del?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 1680 | if ($response->is_success) { | ||
| 1681 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 1682 | } | ||
| 1683 | |||
| 1684 | } | ||
| 1685 | return 0; | ||
| 1686 | } | ||
| 1687 | |||
| 1688 | =head2 file_setting(access_token, hash); | ||
| 1689 | |||
| 1690 | 分享设置 | ||
| 1691 | |||
| 1692 | =head2 SYNOPSIS | ||
| 1693 | |||
| 1694 | L<https://developer.work.weixin.qq.com/document/path/93658#分享设置> | ||
| 1695 | |||
| 1696 | =head3 请求说明: | ||
| 1697 | |||
| 1698 | 该接口用于文件的分享设置。 | ||
| 1699 | |||
| 1700 | =head4 请求包结构体为: | ||
| 1701 | |||
| 1702 | { | ||
| 1703 | "userid": "USERID", | ||
| 1704 | "fileid": "FILDID", | ||
| 1705 | "auth_scope": AUTH_SCOPE, | ||
| 1706 | "auth": 1 | ||
| 1707 | } | ||
| 1708 | |||
| 1709 | =head4 参数说明: | ||
| 1710 | |||
| 1711 | 参数 类型 是否必须 说明 | ||
| 1712 | userid string 是 操作者userid | ||
| 1713 | fileid string 是 文件fileid | ||
| 1714 | auth_scope uint32 是 权限范围:1:指定人 2:企业内 3:企业外 | ||
| 1715 | auth uint32 否 权限信息 | ||
| 1716 | 普通文档: 1:仅浏览(可下载) 4:仅预览(仅专业版企业可设置);如果不填充此字段为保持原有状态 | ||
| 1717 | 微文档: 1:仅浏览(可下载) 2:可编辑;如果不填充此字段为保持原有状态 | ||
| 1718 | |||
| 1719 | =head4 权限说明: | ||
| 1720 | |||
| 1721 | =head3 RETURN 返回结果: | ||
| 1722 | |||
| 1723 | { | ||
| 1724 | "errcode": 0, | ||
| 1725 | "errmsg": "ok" | ||
| 1726 | } | ||
| 1727 | |||
| 1728 | =head4 RETURN 参数说明: | ||
| 1729 | |||
| 1730 | 参数 类型 说明 | ||
| 1731 | errcode int32 错误码 | ||
| 1732 | errmsg string 错误码说明 | ||
| 1733 | |||
| 1734 | =cut | ||
| 1735 | |||
| 1736 | sub file_setting { | ||
| 1737 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 1738 | my $access_token = $_[0]; | ||
| 1739 | my $json = $_[1]; | ||
| 1740 | my $ua = LWP::UserAgent->new; | ||
| 1741 | $ua->timeout(30); | ||
| 1742 | $ua->env_proxy; | ||
| 1743 | |||
| 1744 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_setting?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 1745 | if ($response->is_success) { | ||
| 1746 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 1747 | } | ||
| 1748 | |||
| 1749 | } | ||
| 1750 | return 0; | ||
| 1751 | } | ||
| 1752 | |||
| 1753 | =head2 file_share(access_token, hash); | ||
| 1754 | |||
| 1755 | 获取分享链接 | ||
| 1756 | |||
| 1757 | =head2 SYNOPSIS | ||
| 1758 | |||
| 1759 | L<https://developer.work.weixin.qq.com/document/path/93658#获取分享链接> | ||
| 1760 | |||
| 1761 | =head3 请求说明: | ||
| 1762 | |||
| 1763 | 该接口用于获取文件的分享链接。 | ||
| 1764 | |||
| 1765 | =head4 请求包结构体为: | ||
| 1766 | |||
| 1767 | { | ||
| 1768 | "userid": "USERID", | ||
| 1769 | "fileid": "FILDID" | ||
| 1770 | } | ||
| 1771 | |||
| 1772 | =head4 参数说明: | ||
| 1773 | |||
| 1774 | 参数 类型 是否必须 说明 | ||
| 1775 | userid string 是 操作者userid | ||
| 1776 | fileid string 是 文件fileid | ||
| 1777 | |||
| 1778 | =head4 权限说明: | ||
| 1779 | |||
| 1780 | =head3 RETURN 返回结果: | ||
| 1781 | |||
| 1782 | { | ||
| 1783 | "errcode": 0, | ||
| 1784 | "errmsg": "ok", | ||
| 1785 | "share_url": "SHARE_URL" | ||
| 1786 | } | ||
| 1787 | |||
| 1788 | =head4 RETURN 参数说明: | ||
| 1789 | |||
| 1790 | 参数 类型 说明 | ||
| 1791 | errcode int32 错误码 | ||
| 1792 | errmsg string 错误码说明 | ||
| 1793 | share_url string 分享文件的链接 | ||
| 1794 | |||
| 1795 | =cut | ||
| 1796 | |||
| 1797 | sub file_share { | ||
| 1798 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 1799 | my $access_token = $_[0]; | ||
| 1800 | my $json = $_[1]; | ||
| 1801 | my $ua = LWP::UserAgent->new; | ||
| 1802 | $ua->timeout(30); | ||
| 1803 | $ua->env_proxy; | ||
| 1804 | |||
| 1805 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_share?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 1806 | if ($response->is_success) { | ||
| 1807 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 1808 | } | ||
| 1809 | |||
| 1810 | } | ||
| 1811 | return 0; | ||
| 1812 | } | ||
| 1813 | |||
| 1814 | |||
| 1815 | 1; | ||
| 1816 | __END__ |