work/living.pm untested

filter: Statementstmt 0.0% 0 / 111 Branchbran 0.0% 0 / 36 Conditioncond 0.0% 0 / 54 MC/DCmcdc 0.0% 0 / 27 Subroutinesub 0.0% 0 / 15 Podpod 0.0% 0 / 9 totaltotal 0.0% 0 / 252 CC 19 SCAR 23.2
CC
19
Cov
0%
create
12.0
modify
12.0
cancel
12.0
CRAP 10.2
1 package QQ::weixin::work::living;
2
3 =encoding utf8
4
5 =head1 Name
6
7 QQ::weixin::work::living
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 modify cancel delete_replay_data get_living_code
24 get_user_all_livingid get_living_info get_watch_stat get_living_share_info /;
25
26 =head1 FUNCTION
27
28 =head2 create(access_token, hash);
29
30 创建预约直播
31 最后更新:2023/11/30
32
33 =head2 SYNOPSIS
34
35 L<https://developer.work.weixin.qq.com/document/path/93637>
36
37 =head3 请求说明:
38
39 =head4 请求包结构体为:
40
41 {
42 "anchor_userid": "zhangsan",
43 "theme": "theme",
44 "living_start": 1600000000,
45 "living_duration": 3600,
46 "description": "test description",
47 "type": 4,
48 "agentid" : 1000014,
49 "remind_time": 60,
50 "activity_cover_mediaid": "MEDIA_ID",
51 "activity_share_mediaid": "MEDIA_ID",
52 "activity_detail":
53 {
54 "description": "活动描述,非活动类型的直播不用传",
55 "image_list": [
56 "MEDIA_ID_1",
57 "MEDIA_ID_2"
58 ]
59 }
60 }
61
62 =head4 参数说明:
63
64 参数 必须 说明
65 access_token 是 调用接口凭证。获取方法查看“获取access_token”
66 anchor_userid 是 直播发起者的userid
67 theme 是 直播的标题,最多支持20个utf8字符
68 living_start 是 直播开始时间的unix时间戳
69 living_duration 是 直播持续时长
70 type 否 直播的类型,0:通用直播,1:小班课,2:大班课,3:企业培训,4:活动直播,默认 0。其中大班课和小班课仅k12学校和IT行业类型能够发起
71 description 否 直播的简介,最多支持100个utf8字符,仅对“通用直播”、“小班课”、“大班课”和“企业培训”生效,“活动直播”简介通过activity_detail.description控制
72 agentid 否 授权方安装的应用agentid。仅旧的第三方多应用套件需要填此参数
73 remind_time 否 指定直播开始前多久提醒用户,相对于living_start前的秒数,默认为0
74 activity_cover_mediaid 否 活动直播特定参数,直播间封面图的mediaId
75 activity_share_mediaid 否 活动直播特定参数,直播分享卡片图的mediaId
76 activity_detail 否 活动直播特定参数,活动直播详情信息
77 activity_detail.description 否 活动直播特定参数,活动直播简介
78 activity_detail.image_list 否 活动直播特定参数,活动直播附图的mediaId列表,最多支持传5张,超过五张取前五张
79
80 =head4 权限说明:
81
82 应用类型 权限要求
83 自建应用 配置到「上课直播/直播 - 可调用接口的应用」中
84 代开发应用 具有「直播」权限
85 第三方应用 具有「直播」权限
86
87 =head3 RETURN 返回结果:
88
89 {
90 "errcode": 0,
91 "errmsg": "ok",
92 "livingid": "XXXXXXXXX"
93 }
94
95 =head4 RETURN 参数说明:
96
97 参数 说明
98 errcode 返回码
99 errmsg 对返回码的文本描述内容
100 livingid 直播id,通过此id可调用“进入直播”接口(包括小程序接口和JS-SDK接口),以实现主播到点后的开播操作,以及观众进入直播详情预约和观看直播
101
102 =cut
103
104 sub create {
105 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
106 my $access_token = $_[0];
107 my $json = $_[1];
108 my $ua = LWP::UserAgent->new;
109 $ua->timeout(30);
110 $ua->env_proxy;
111
112 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/living/create?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
113 if ($response->is_success) {
114 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
115 }
116
117 }
118 return 0;
119 }
120
121 =head2 modify(access_token, hash);
122
123 修改预约直播
124 最后更新:2023/11/30
125
126 =head2 SYNOPSIS
127
128 L<https://developer.work.weixin.qq.com/document/path/93640>
129
130 =head3 请求说明:
131
132 =head4 请求包结构体为:
133
134 {
135 "livingid": "XXXXXXXXX",
136 "theme": "theme",
137 "living_start": 1600100000,
138 "living_duration": 3600,
139 "description": "test description",
140 "type": 1,
141 "remind_time": 60
142 }
143
144 =head4 参数说明:
145
146 参数 必须 说明
147 access_token 是 调用接口凭证。获取方法查看“获取access_token”
148 livingid 是 直播id,仅允许修改预约状态下的直播id
149 theme 否 直播的标题,最多支持60个字节
150 living_start 否 直播开始时间的unix时间戳
151 living_duration 否 直播持续时长
152 type 否 直播的类型,0:通用直播,1:小班课,2:大班课,3:企业培训,4:活动直播。其中大班课和小班课仅k12学校和IT行业类型能够发起
153 description 否 直播的简介,最多支持300个字节
154 remind_time 否 指定直播开始前多久提醒用户,相对于living_start前的秒数,默认为0
155
156 =head4 权限说明:
157
158 应用类型 权限要求
159 自建应用 配置到「上课直播/直播 - 可调用接口的应用」中
160 代开发应用 具有「直播」权限
161 第三方应用 具有「直播」权限
162
163 仅允许修改当前应用创建的直播。
164
165 =head3 RETURN 返回结果:
166
167 {
168 "errcode": 0,
169 "errmsg": "ok"
170 }
171
172 =head4 RETURN 参数说明:
173
174 参数 说明
175 errcode 返回码
176 errmsg 对返回码的文本描述内容
177
178 =cut
179
180 sub modify {
181 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
182 my $access_token = $_[0];
183 my $json = $_[1];
184 my $ua = LWP::UserAgent->new;
185 $ua->timeout(30);
186 $ua->env_proxy;
187
188 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/living/modify?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
189 if ($response->is_success) {
190 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
191 }
192
193 }
194 return 0;
195 }
196
197 =head2 cancel(access_token, hash);
198
199 取消预约直播
200 最后更新:2023/11/30
201
202 =head2 SYNOPSIS
203
204 L<https://developer.work.weixin.qq.com/document/path/93638>
205
206 =head3 请求说明:
207
208 =head4 请求包结构体为:
209
210 {
211 "livingid": "XXXXXXXXX"
212 }
213
214 =head4 参数说明:
215
216 参数 必须 说明
217 access_token 是 调用接口凭证。获取方法查看“获取access_token”
218 livingid 是 直播id,仅允许取消预约状态下的直播id
219
220 =head4 权限说明:
221
222 应用类型 权限要求
223 自建应用 配置到「上课直播/直播 - 可调用接口的应用」中
224 代开发应用 具有「直播」权限
225 第三方应用 具有「直播」权限
226
227 仅允许取消当前应用创建的直播。
228
229 =head3 RETURN 返回结果:
230
231 {
232 "errcode": 0,
233 "errmsg": "ok"
234 }
235
236 =head4 RETURN 参数说明:
237
238 参数 说明
239 errcode 返回码
240 errmsg 对返回码的文本描述内容
241
242 =cut
243
244 sub cancel {
245 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
246 my $access_token = $_[0];
247 my $json = $_[1];
248 my $ua = LWP::UserAgent->new;
249 $ua->timeout(30);
250 $ua->env_proxy;
251
252 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/living/cancel?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
253 if ($response->is_success) {
254 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
255 }
256
257 }
258 return 0;
259 }
260
261 =head2 delete_replay_data(access_token, hash);
262
263 删除直播回放
264 最后更新:2023/12/08
265
266 =head2 SYNOPSIS
267
268 L<https://developer.work.weixin.qq.com/document/path/93874>
269
270 =head3 请求说明:
271
272 =head4 请求包结构体为:
273
274 {
275 "livingid": "XXXXXXXXX"
276 }
277
278 =head4 参数说明:
279
280 参数 必须 说明
281 access_token 是 调用接口凭证。获取方法查看“获取access_token”
282 livingid 是 直播id
283
284 =head4 权限说明:
285
286 应用类型 权限要求
287 自建应用 配置到「上课直播/直播 - 可调用接口的应用」中
288 代开发应用 具有「直播」权限
289 第三方应用 具有「直播」权限
290
291 仅允许取消当前应用创建的直播。
292 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
293
294 =head3 RETURN 返回结果:
295
296 {
297 "errcode": 0,
298 "errmsg": "ok"
299 }
300
301 =head4 RETURN 参数说明:
302
303 参数 说明
304 errcode 返回码
305 errmsg 对返回码的文本描述内容
306
307 =cut
308
309 sub delete_replay_data {
310 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
311 my $access_token = $_[0];
312 my $json = $_[1];
313 my $ua = LWP::UserAgent->new;
314 $ua->timeout(30);
315 $ua->env_proxy;
316
317 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/living/delete_replay_data?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
318 if ($response->is_success) {
319 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
320 }
321
322 }
323 return 0;
324 }
325
326 =head2 在微信中观看直播或直播回放
327
328 最后更新:2023/12/01
329
330 =head2 get_living_code(access_token, hash);
331
332 获取微信观看直播凭证
333
334 =head2 SYNOPSIS
335
336 L<https://developer.work.weixin.qq.com/document/path/93641#获取微信观看直播凭证>
337
338 =head3 请求说明:
339
340 通过微信观看直播的凭证,可在微信中H5或小程序页面唤起企业微信直播小程序,并进入对应直播或直播回放。
341
342 =head4 请求包结构体为:
343
344 {
345 "livingid": "XXXXXXXXX",
346 "openid": "abcopenid"
347 }
348
349 =head4 参数说明:
350
351 参数 必须 说明
352 access_token 是 调用接口凭证。获取方法查看“获取access_token”
353 livingid 是 直播id
354 openid 是 微信用户的openid
355
356 =head4 权限说明:
357
358 应用类型 权限要求
359 自建应用 配置到「上课直播/直播 - 可调用接口的应用」中
360 代开发应用 具有「直播」权限
361 第三方应用 具有「直播」权限
362
363 仅允许获取当前应用创建的微信观看直播凭证。
364 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
365
366 =head3 RETURN 返回结果:
367
368 {
369 "errcode": 0,
370 "errmsg": "ok",
371 "living_code": "abcdef"
372 }
373
374 =head4 RETURN 参数说明:
375
376 参数 说明
377 errcode 返回码
378 errmsg 对返回码的文本描述内容
379 living_code 微信观看直播凭证,5分钟内可以重复使用,且仅能在微信上使用。开发者获取到该凭证后可以在微信H5页面或小程序进入直播或直播回放页
380
381 =cut
382
383 sub get_living_code {
384 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
385 my $access_token = $_[0];
386 my $json = $_[1];
387 my $ua = LWP::UserAgent->new;
388 $ua->timeout(30);
389 $ua->env_proxy;
390
391 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/living/get_living_code?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
392 if ($response->is_success) {
393 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
394 }
395
396 }
397 return 0;
398 }
399
400 =head2 get_user_all_livingid(access_token, hash);
401
402 获取成员直播ID列表
403 最后更新:2023/12/01
404
405 =head2 SYNOPSIS
406
407 L<https://developer.work.weixin.qq.com/document/path/93634>
408
409 =head3 请求说明:
410
411 通过此接口可以获取指定成员的所有直播ID
412
413 =head4 请求包结构体为:
414
415 {
416 "userid": "USERID",
417 "cursor": "NEXT_KEY",
418 "limit": 20
419 }
420
421 =head4 参数说明:
422
423 参数 必须 说明
424 access_token 是 调用接口凭证
425 userid 是 企业成员的userid
426 cursor 否 上一次调用时返回的next_cursor,第一次拉取可以不填
427 limit 否 每次拉取的数据量,建议填20,默认值和最大值都为100
428
429 =head4 权限说明:
430
431 应用类型 权限要求
432 自建应用 配置到「上课直播/直播 - 可调用接口的应用」中
433 代开发应用 具有「直播」权限
434 第三方应用 具有「直播」权限
435
436 只能获取本应用创建的直播
437 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
438
439 =head3 RETURN 返回结果:
440
441 {
442 "errcode": 0,
443 "errmsg": "ok",
444 "next_cursor": "next_cursor",
445 "livingid_list":[
446 "livingid1",
447 "livingid2"
448 ]
449 }
450
451 =head4 RETURN 参数说明:
452
453 参数 说明
454 errcode 返回码
455 errmsg 对返回码的文本描述内容
456 next_cursor 当前数据最后一个key值,如果下次调用带上该值则从该key值往后拉,用于实现分页拉取,返回空字符串代表已经是最后一页
457 livingid_list 直播ID列表
458
459 =cut
460
461 sub get_user_all_livingid {
462 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
463 my $access_token = $_[0];
464 my $json = $_[1];
465 my $ua = LWP::UserAgent->new;
466 $ua->timeout(30);
467 $ua->env_proxy;
468
469 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/living/get_user_all_livingid?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
470 if ($response->is_success) {
471 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
472 }
473
474 }
475 return 0;
476 }
477
478 =head2 get_living_info(access_token,livingid);
479
480 获取直播详情
481 最后更新:2023/12/01
482
483 =head2 SYNOPSIS
484
485 L<https://developer.work.weixin.qq.com/document/path/93635>
486
487 =head3 请求说明:
488
489 =head4 参数说明:
490
491 参数 必须 说明
492 access_token 是 调用接口凭证
493 livingid 是 直播ID
494
495 =head4 权限说明:
496
497 应用类型 权限要求
498 自建应用 配置到「上课直播/直播 - 可调用接口的应用」中
499 代开发应用 具有「直播」权限
500 第三方应用 具有「直播」权限
501
502 只能获取本应用创建的直播
503 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
504
505 =head3 RETURN 返回结果:
506
507 {
508 "errcode": 0,
509 "errmsg": "ok",
510 "living_info":{
511 "theme": "直角三角形讲解",
512 "living_start": 1586405229,
513 "living_duration": 1800,
514 "status ": 3,
515 "reserve_start": 1586405239,
516 "reserve_living_duration": 1600,
517 "description": "小学数学精选课程",
518 "anchor_userid": "zhangsan",
519 "main_department": 1,
520 "viewer_num": 100,
521 "comment_num": 110,
522 "mic_num": 120,
523 "open_replay": 1,
524 "replay_status": 2,
525 "type": 0,
526 "push_stream_url": "https://www.qq.test.com",
527 "online_count": 1,
528 "subscribe_count": 1
529 }
530 }
531
532 =head4 RETURN 参数说明:
533
534 参数 说明
535 errcode 返回码
536 errmsg 对返回码的文本描述内容
537 living_info 直播信息
538 living_info.theme 直播主题
539 living_info.living_start 直播开始时间戳
540 living_info.living_duration 直播时长,单位为秒
541 living_info.status 直播的状态,0:预约中,1:直播中,2:已结束,3:已过期,4:已取消
542 living_info.reserve_start 直播预约的开始时间戳
543 living_info.reserve_living_duration 直播预约时长,单位为秒
544 living_info.description 直播的描述,最多支持100个汉字
545 living_info.anchor_userid 主播的userid
546 living_info.main_department 主播所在主部门id
547 living_info.viewer_num 观看直播总人数
548 living_info.comment_num 评论数
549 living_info.mic_num 连麦发言人数
550 living_info.open_replay 是否开启回放,1表示开启,0表示关闭
551 living_info.replay_status open_replay为1时才返回该字段。0表示生成成功,1表示生成中,2表示回放已删除,3表示生成失败
552 living_info.type 直播的类型,0:通用直播,1:小班课,2:大班课,3:企业培训,4:活动直播
553 living_info.push_stream_url 推流地址,仅直播类型为活动直播并且直播状态是待开播返回该字段
554 living_info.online_count 当前在线观看人数
555 living_info.subscribe_count 直播预约人数
556
557 =cut
558
559 sub get_living_info {
560 if ( @_ && $_[0] && $_[1] ) {
561 my $access_token = $_[0];
562 my $livingid = $_[1];
563 my $ua = LWP::UserAgent->new;
564 $ua->timeout(30);
565 $ua->env_proxy;
566
567 my $response = $ua->get("https://qyapi.weixin.qq.com/cgi-bin/living/get_living_info?access_token=$access_token&livingid=$livingid");
568 if ($response->is_success) {
569 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
570 }
571
572 }
573 return 0;
574 }
575
576 =head2 get_watch_stat(access_token, hash);
577
578 获取直播观看明细
579 最后更新:2023/12/01
580
581 =head2 SYNOPSIS
582
583 L<https://developer.work.weixin.qq.com/document/path/93636>
584
585 =head3 请求说明:
586
587 通过该接口可以获取所有观看直播的人员统计
588
589 =head4 请求包结构体为:
590
591 {
592 "livingid": "livingid1",
593 "next_key": "NEXT_KEY"
594 }
595
596 =head4 参数说明:
597
598 参数 必须 说明
599 access_token 是 调用接口凭证
600 livingid 是 直播的id
601 next_key 否 上一次调用时返回的next_key,初次调用可以填"0"
602
603 =head4 权限说明:
604
605 应用类型 权限要求
606 自建应用 配置到「上课直播/直播 - 可调用接口的应用」中
607 代开发应用 具有「直播」权限
608 第三方应用 具有「直播」权限
609
610 能获取本应用创建的直播
611 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
612
613 =head3 RETURN 返回结果:
614
615 {
616 "errcode": 0,
617 "errmsg": "ok",
618 "ending":1,
619 "next_key": "NEXT_KEY",
620 "stat_info":{
621 "users":[
622 {
623 "userid": "userid",
624 "watch_time": 30,
625 "is_comment": 1,
626 "is_mic": 1
627 }
628 ],
629 "external_users":[
630 {
631 "external_userid": "external_userid1",
632 "type": 1,
633 "name": "user name",
634 "watch_time": 30,
635 "is_comment": 1,
636 "is_mic": 1
637 },
638 {
639 "external_userid": "external_userid2",
640 "type": 2,
641 "name": "user_name",
642 "watch_time": 30,
643 "is_comment": 1,
644 "is_mic": 1
645 }
646 ],
647 }
648 }
649
650 =head4 RETURN 参数说明:
651
652 参数 说明
653 errcode 返回码
654 errmsg 对返回码的文本描述内容
655 ending 是否结束。0:表示还有更多数据,需要继续拉取,1:表示已经拉取完所有数据。注意只能根据该字段判断是否已经拉完数据
656 next_key 当前数据最后一个key值,如果下次调用带上该值则从该key值往后拉,用于实现分页拉取
657 stat_info 统计信息列表
658 stat_info.users 观看直播的企业成员列表
659 stat_info.users.userid 企业成员的userid
660 stat_info.users.watch_time 观看时长,单位为秒
661 stat_info.users.is_comment 是否评论。0-否;1-是
662 stat_info.users.is_mic 是否连麦发言。0-否;1-是
663 stat_info.users.invitor_userid 邀请人的userid
664 stat_info.users.invitor_external_userid 邀请人的external_userid
665 stat_info.external_users 观看直播的外部成员列表
666 stat_info.external_users.external_userid 外部成员的userid
667 stat_info.external_users.type 外部成员类型,1表示该外部成员是微信用户,2表示该外部成员是企业微信用户
668 stat_info.external_users.name 外部成员的名称
669 stat_info.external_users.watch_time 观看时长,单位为秒
670 stat_info.external_users.is_comment 是否评论。0-否;1-是
671 stat_info.external_users.is_mic 是否连麦发言。0-否;1-是
672 stat_info.external_users.invitor_userid 邀请人的userid,邀请人为企业内部成员时返回(观众首次进入直播时,其使用的直播卡片/二维码所对应的分享人;仅“推广产品”直播支持)
673 stat_info.external_users.invitor_external_userid 邀请人的external_userid,邀请人为非企业内部成员时返回(观众首次进入直播时,其使用的直播卡片/二维码所对应的分享人;仅“推广产品”直播支持)
674
675 =cut
676
677 sub get_watch_stat {
678 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
679 my $access_token = $_[0];
680 my $json = $_[1];
681 my $ua = LWP::UserAgent->new;
682 $ua->timeout(30);
683 $ua->env_proxy;
684
685 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/living/get_watch_stat?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
686 if ($response->is_success) {
687 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
688 }
689
690 }
691 return 0;
692 }
693
694 =head2 get_living_share_info(access_token, hash);
695
696 获取跳转小程序商城的直播观众信息
697 最后更新:2023/12/01
698
699 =head2 SYNOPSIS
700
701 L<https://developer.work.weixin.qq.com/document/path/94442>
702
703 =head3 请求说明:
704
705 通过此接口,开发者可获取跳转小程序商城的直播间(“推广产品”直播)观众id、邀请人id及对应直播间id,以打通卖货直播的“人货场”信息闭环。
706
707 =head4 请求包结构体为:
708
709 {
710 "ww_share_code": "CODE"
711 }
712
713 =head4 参数说明:
714
715 参数 必须 说明
716 access_token 是 调用接口凭证
717 ww_share_code 是 “推广产品”直播观众跳转小程序商城时会在小程序path中带上ww_share_code=xxxxx参数,ww_share_code五分钟内有效
718
719 =head4 权限说明:
720
721 应用类型 权限要求
722 自建应用 配置到「上课直播/直播 - 可调用接口的应用」中
723 代开发应用 具有「直播」权限
724 第三方应用 具有「直播」权限
725
726 跳转的小程序需要与企业有绑定关系
727 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
728
729 =head3 RETURN 返回结果:
730
731 {
732 "errcode": 0,
733 "errmsg": "ok",
734 "livingid": "livingid",
735 "viewer_userid": "viewer_userid",
736 "viewer_external_userid": "viewer_external_userid",
737 "invitor_userid": "invitor_userid",
738 "invitor_external_userid": "invitor_external_userid"
739 }
740
741 =head4 RETURN 参数说明:
742
743 参数 说明
744 errcode 返回码
745 errmsg 对返回码的文本描述内容
746 livingid 直播id
747 viewer_userid 观众的userid,观众为企业内部成员时返回
748 viewer_external_userid 观众的external_userid,观众为非企业内部成员时返回
749 invitor_userid 邀请人的userid,邀请人为企业内部成员时返回(观众首次进入直播时,其使用的直播卡片/二维码所对应的分享人)
750 invitor_external_userid 邀请人的external_userid,邀请人为非企业内部成员时返回 (观众首次进入直播时,其使用的直播卡片/二维码所对应的分享人)
751
752 =cut
753
754 sub get_living_share_info {
755 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
756 my $access_token = $_[0];
757 my $json = $_[1];
758 my $ua = LWP::UserAgent->new;
759 $ua->timeout(30);
760 $ua->env_proxy;
761
762 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/living/get_living_share_info?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
763 if ($response->is_success) {
764 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
765 }
766
767 }
768 return 0;
769 }
770
771
772 1;
773 __END__