wechat 0.11.2 → 0.11.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +6 -0
- data/README-CN.md +77 -57
- data/README.md +78 -57
- data/bin/wechat +10 -0
- data/lib/wechat/api_base.rb +5 -0
- data/lib/wechat/api_loader.rb +3 -2
- data/lib/wechat/concern/common.rb +20 -13
- data/lib/wechat/corp_api.rb +1 -3
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdf26f461c946f08f6747800211b8165347abf0f916ca81e8e80961120f03c7b
|
4
|
+
data.tar.gz: ce946c0fa241b1af9d3668436b252fcba6151fed0ce1c0fce2d4b8a3b1455372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3cb219e0a7cdd7659db6cc6bd8e670a4ec94c1b57edf20804b77ca3a3d02f7bb7c90565c4c1a0530203706bea5f7d3d0e36e2411ef0cbc9633fcc0533e693b4
|
7
|
+
data.tar.gz: c95e46973167ca513999c68851cb7f86719f756548fe635de4be16c7bd7ae3ce2cf15fd381b5ace48b0665eb1767e0c41a4f769c746e71f52c4a80a8efd19472
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v0.11.3 (released at 07/02/2019)
|
4
|
+
|
5
|
+
* New addvoicetorecofortext and queryrecoresultfortext support.
|
6
|
+
* improve existing class detect by @3014zhangshuo #261
|
7
|
+
* new wxa_get_wxacode_unlimit API for miniapp by @paicha #260
|
8
|
+
|
3
9
|
## v0.11.2 (released at 05/08/2019)
|
4
10
|
|
5
11
|
* bugfix short_url to shorturl in wechat console tool by @yuanxinyu #259
|
data/README-CN.md
CHANGED
@@ -346,7 +346,9 @@ wechat gems 内部不会检查权限。但因公众号类型不同,和微信
|
|
346
346
|
```
|
347
347
|
$ wechat
|
348
348
|
Wechat Public Account commands:
|
349
|
+
wechat addvoicetorecofortext [VOICE_ID] # AI开放接口-提交语音
|
349
350
|
wechat callbackip # 获取微信服务器IP地址
|
351
|
+
wechat clear_quota # 接口调用次数清零
|
350
352
|
wechat custom_image [OPENID, IMAGE_PATH] # 发送图片客服消息
|
351
353
|
wechat custom_music [OPENID, THUMBNAIL_PATH, MUSIC_URL] # 发送音乐客服消息
|
352
354
|
wechat custom_news [OPENID, NEWS_YAML_PATH] # 发送图文客服消息
|
@@ -380,7 +382,8 @@ Wechat Public Account commands:
|
|
380
382
|
wechat qrcode_create_limit_scene [SCENE_ID_OR_STR] # 请求永久二维码
|
381
383
|
wechat qrcode_create_scene [SCENE_ID_OR_STR, EXPIRE_SECONDS] # 请求临时二维码
|
382
384
|
wechat qrcode_download [TICKET, QR_CODE_PIC_PATH] # 通过ticket下载二维码
|
383
|
-
wechat
|
385
|
+
wechat queryrecoresultfortext [VOICE_ID] # AI开放接口-获取语音识别结果
|
386
|
+
wechat shorturl [LONG_URL] # 长链接转短链接
|
384
387
|
wechat tag [TAGID] # 获取标签下粉丝列表
|
385
388
|
wechat tag_add_user [TAG_ID, OPEN_IDS] # 批量为用户打标签
|
386
389
|
wechat tag_create [TAGNAME, TAG_ID] # 创建标签
|
@@ -402,62 +405,64 @@ Wechat Public Account commands:
|
|
402
405
|
```
|
403
406
|
$ wechat
|
404
407
|
Wechat Enterprise Account commands:
|
405
|
-
wechat agent [AGENT_ID]
|
406
|
-
wechat agent_list
|
407
|
-
wechat batch_job_result [JOB_ID]
|
408
|
-
wechat batch_replaceparty [BATCH_PARTY_CSV_MEDIA_ID]
|
409
|
-
wechat batch_replaceuser [BATCH_USER_CSV_MEDIA_ID]
|
410
|
-
wechat batch_syncuser [SYNC_USER_CSV_MEDIA_ID]
|
411
|
-
wechat callbackip
|
412
|
-
wechat
|
413
|
-
wechat
|
414
|
-
wechat
|
415
|
-
wechat
|
416
|
-
wechat
|
417
|
-
wechat
|
418
|
-
wechat
|
419
|
-
wechat
|
420
|
-
wechat
|
421
|
-
wechat
|
422
|
-
wechat
|
423
|
-
wechat
|
424
|
-
wechat
|
425
|
-
wechat
|
426
|
-
wechat
|
427
|
-
wechat
|
428
|
-
wechat
|
429
|
-
wechat
|
430
|
-
wechat
|
431
|
-
wechat
|
432
|
-
wechat
|
433
|
-
wechat
|
434
|
-
wechat
|
435
|
-
wechat
|
436
|
-
wechat
|
437
|
-
wechat
|
438
|
-
wechat
|
439
|
-
wechat
|
440
|
-
wechat
|
441
|
-
wechat
|
442
|
-
wechat
|
443
|
-
wechat
|
444
|
-
wechat
|
445
|
-
wechat
|
446
|
-
wechat
|
447
|
-
wechat
|
448
|
-
wechat
|
449
|
-
wechat
|
450
|
-
wechat
|
451
|
-
wechat
|
452
|
-
wechat
|
453
|
-
wechat
|
454
|
-
wechat
|
455
|
-
wechat
|
408
|
+
wechat agent [AGENT_ID] # 获取企业号应用详情
|
409
|
+
wechat agent_list # 获取应用概况列表
|
410
|
+
wechat batch_job_result [JOB_ID] # 获取异步任务结果
|
411
|
+
wechat batch_replaceparty [BATCH_PARTY_CSV_MEDIA_ID] # 全量覆盖部门
|
412
|
+
wechat batch_replaceuser [BATCH_USER_CSV_MEDIA_ID] # 全量覆盖成员
|
413
|
+
wechat batch_syncuser [SYNC_USER_CSV_MEDIA_ID] # 增量更新成员
|
414
|
+
wechat callbackip # 获取微信服务器IP地址
|
415
|
+
wechat clear_quota # 接口调用次数清零
|
416
|
+
wechat convert_to_openid [USER_ID] # userid转换成openid
|
417
|
+
wechat custom_image [OPENID, IMAGE_PATH] # 发送图片客服消息
|
418
|
+
wechat custom_music [OPENID, THUMBNAIL_PATH, MUSIC_URL] # 发送音乐客服消息
|
419
|
+
wechat custom_news [OPENID, NEWS_YAML_PATH] # 发送图文客服消息
|
420
|
+
wechat custom_text [OPENID, TEXT_MESSAGE] # 发送文字客服消息
|
421
|
+
wechat custom_video [OPENID, VIDEO_PATH] # 发送视频客服消息
|
422
|
+
wechat custom_voice [OPENID, VOICE_PATH] # 发送语音客服消息
|
423
|
+
wechat department [DEPARTMENT_ID] # 获取部门列表
|
424
|
+
wechat department_create [NAME, PARENT_ID] # 创建部门
|
425
|
+
wechat department_delete [DEPARTMENT_ID] # 删除部门
|
426
|
+
wechat department_update [DEPARTMENT_ID, NAME] # 更新部门
|
427
|
+
wechat getusercumulate [BEGIN_DATE, END_DATE] # 获取累计用户数据
|
428
|
+
wechat getusersummary [BEGIN_DATE, END_DATE] # 获取用户增减数据
|
429
|
+
wechat invite_user [USER_ID] # 邀请成员关注
|
430
|
+
wechat material [MEDIA_ID, PATH] # 永久媒体下载
|
431
|
+
wechat material_add [MEDIA_TYPE, PATH] # 永久媒体上传
|
432
|
+
wechat material_count # 获取永久素材总数
|
433
|
+
wechat material_delete [MEDIA_ID] # 删除永久素材
|
434
|
+
wechat material_list [TYPE, OFFSET, COUNT] # 获取永久素材列表
|
435
|
+
wechat media [MEDIA_ID, PATH] # 媒体下载
|
436
|
+
wechat media_create [MEDIA_TYPE, PATH] # 媒体上传
|
437
|
+
wechat media_hq [MEDIA_ID, PATH] # 高清音频媒体下载
|
438
|
+
wechat media_uploadimg [IMAGE_PATH] # 上传图文消息内的图片
|
439
|
+
wechat menu # 当前菜单
|
440
|
+
wechat menu_addconditional [CONDITIONAL_MENU_YAML_PATH] # 创建个性化菜单
|
441
|
+
wechat menu_create [MENU_YAML_PATH] # 创建菜单
|
442
|
+
wechat menu_delconditional [MENU_ID] # 删除个性化菜单
|
443
|
+
wechat menu_delete # 删除菜单
|
444
|
+
wechat menu_trymatch [USER_ID] # 测试个性化菜单匹配结果
|
445
|
+
wechat message_send [OPENID, TEXT_MESSAGE] # 发送文字消息
|
446
|
+
wechat qrcode_download [TICKET, QR_CODE_PIC_PATH] # 通过ticket下载二维码
|
447
|
+
wechat tag [TAG_ID] # 获取标签成员
|
448
|
+
wechat tag_add_department [TAG_ID, PARTY_IDS] # 增加标签部门
|
449
|
+
wechat tag_add_user [TAG_ID, USER_IDS] # 增加标签成员
|
450
|
+
wechat tag_create [TAGNAME, TAG_ID] # 创建标签
|
451
|
+
wechat tag_del_department [TAG_ID, PARTY_IDS] # 删除标签部门
|
452
|
+
wechat tag_del_user [TAG_ID, USER_IDS] # 删除标签成员
|
453
|
+
wechat tag_delete [TAG_ID] # 删除标签
|
454
|
+
wechat tag_update [TAG_ID, TAGNAME] # 更新标签名字
|
455
|
+
wechat tags # 获取所有标签
|
456
|
+
wechat template_message [OPENID, TEMPLATE_YAML_PATH] # 模板消息接口
|
457
|
+
wechat upload_replaceparty [BATCH_PARTY_CSV_PATH] # 上传文件方式全量覆盖部门
|
458
|
+
wechat upload_replaceuser [BATCH_USER_CSV_PATH] # 上传文件方式全量覆盖成员
|
459
|
+
wechat user [OPEN_ID] # 获取用户基本信息
|
460
|
+
wechat user_batchdelete [USER_ID_LIST] # 批量删除成员
|
456
461
|
wechat user_create [USER_ID, NAME] # 创建成员
|
457
|
-
wechat user_delete [USER_ID]
|
458
|
-
wechat user_list [DEPARTMENT_ID]
|
459
|
-
wechat user_simplelist [DEPARTMENT_ID]
|
460
|
-
wechat user_update_remark [OPEN_ID, REMARK]
|
462
|
+
wechat user_delete [USER_ID] # 删除成员
|
463
|
+
wechat user_list [DEPARTMENT_ID] # 获取部门成员详情
|
464
|
+
wechat user_simplelist [DEPARTMENT_ID] # 获取部门成员
|
465
|
+
wechat user_update_remark [OPEN_ID, REMARK] # 设置备注名
|
461
466
|
```
|
462
467
|
|
463
468
|
注意:replaceparty 全量覆盖部门只支持单个根节点作为部门,不支持平行多根节点。
|
@@ -627,6 +632,15 @@ end
|
|
627
632
|
|
628
633
|
可以通过`Wechat.api`在任意地方使用wechat api的功能。
|
629
634
|
|
635
|
+
下面以通过`rails console`调用微信AI开放接口的语音识别为例:
|
636
|
+
|
637
|
+
```bash
|
638
|
+
# Audio file with ID3 version 2.4.0, contains:MPEG ADTS, layer III, v2, 40 kbps, 16 kHz, Monaural
|
639
|
+
test_voice_file='test_voice.mp3'
|
640
|
+
Wechat.api.addvoicetorecofortext('test_voice_id', File.open(test_voice_file))
|
641
|
+
Wechat.api.queryrecoresultfortext 'test_voice_id'
|
642
|
+
```
|
643
|
+
|
630
644
|
## wechat_responder - Rails Responder Controller DSL
|
631
645
|
|
632
646
|
为了在Rails app中响应用户的消息,开发者需要创建一个wechat responder controller. 首先在router中定义
|
@@ -711,7 +725,13 @@ class WechatsController < ActionController::Base
|
|
711
725
|
|
712
726
|
# 处理语音信息
|
713
727
|
on :voice do |request|
|
714
|
-
|
728
|
+
# 直接语音音返回给用户
|
729
|
+
# request.reply.voice(request[:MediaId])
|
730
|
+
|
731
|
+
voice_id = request[:MediaId]
|
732
|
+
# 开通语音识别后,用户每次发送语音给服务号时,微信会在推送的语音消息XML数据包中,增加一个Recognition字段
|
733
|
+
recognition = request[:Recognition]
|
734
|
+
request.reply.text "#{voice_id} #{recognition}"
|
715
735
|
end
|
716
736
|
|
717
737
|
# 处理视频信息
|
data/README.md
CHANGED
@@ -377,7 +377,9 @@ Feel safe if you can not read Chinese in the comments, it's kept there in order
|
|
377
377
|
```
|
378
378
|
$ wechat
|
379
379
|
Wechat Public Account commands:
|
380
|
+
wechat addvoicetorecofortext [VOICE_ID] # AI开放接口-提交语音
|
380
381
|
wechat callbackip # 获取微信服务器IP地址
|
382
|
+
wechat clear_quota # 接口调用次数清零
|
381
383
|
wechat custom_image [OPENID, IMAGE_PATH] # 发送图片客服消息
|
382
384
|
wechat custom_music [OPENID, THUMBNAIL_PATH, MUSIC_URL] # 发送音乐客服消息
|
383
385
|
wechat custom_news [OPENID, NEWS_YAML_PATH] # 发送图文客服消息
|
@@ -411,7 +413,8 @@ Wechat Public Account commands:
|
|
411
413
|
wechat qrcode_create_limit_scene [SCENE_ID_OR_STR] # 请求永久二维码
|
412
414
|
wechat qrcode_create_scene [SCENE_ID_OR_STR, EXPIRE_SECONDS] # 请求临时二维码
|
413
415
|
wechat qrcode_download [TICKET, QR_CODE_PIC_PATH] # 通过ticket下载二维码
|
414
|
-
wechat
|
416
|
+
wechat queryrecoresultfortext [VOICE_ID] # AI开放接口-获取语音识别结果
|
417
|
+
wechat shorturl [LONG_URL] # 长链接转短链接
|
415
418
|
wechat tag [TAGID] # 获取标签下粉丝列表
|
416
419
|
wechat tag_add_user [TAG_ID, OPEN_IDS] # 批量为用户打标签
|
417
420
|
wechat tag_create [TAGNAME, TAG_ID] # 创建标签
|
@@ -434,62 +437,64 @@ Wechat Public Account commands:
|
|
434
437
|
```
|
435
438
|
$ wechat
|
436
439
|
Wechat Enterprise Account commands:
|
437
|
-
wechat agent [AGENT_ID]
|
438
|
-
wechat agent_list
|
439
|
-
wechat batch_job_result [JOB_ID]
|
440
|
-
wechat batch_replaceparty [BATCH_PARTY_CSV_MEDIA_ID]
|
441
|
-
wechat batch_replaceuser [BATCH_USER_CSV_MEDIA_ID]
|
442
|
-
wechat batch_syncuser [SYNC_USER_CSV_MEDIA_ID]
|
443
|
-
wechat callbackip
|
444
|
-
wechat
|
445
|
-
wechat
|
446
|
-
wechat
|
447
|
-
wechat
|
448
|
-
wechat
|
449
|
-
wechat
|
450
|
-
wechat
|
451
|
-
wechat
|
452
|
-
wechat
|
453
|
-
wechat
|
454
|
-
wechat
|
455
|
-
wechat
|
456
|
-
wechat
|
457
|
-
wechat
|
458
|
-
wechat
|
459
|
-
wechat
|
460
|
-
wechat
|
461
|
-
wechat
|
462
|
-
wechat
|
463
|
-
wechat
|
464
|
-
wechat
|
465
|
-
wechat
|
466
|
-
wechat
|
467
|
-
wechat
|
468
|
-
wechat
|
469
|
-
wechat
|
470
|
-
wechat
|
471
|
-
wechat
|
472
|
-
wechat
|
473
|
-
wechat
|
474
|
-
wechat
|
475
|
-
wechat
|
476
|
-
wechat
|
477
|
-
wechat
|
478
|
-
wechat
|
479
|
-
wechat
|
480
|
-
wechat
|
481
|
-
wechat
|
482
|
-
wechat
|
483
|
-
wechat
|
484
|
-
wechat
|
485
|
-
wechat
|
486
|
-
wechat
|
487
|
-
wechat
|
440
|
+
wechat agent [AGENT_ID] # 获取企业号应用详情
|
441
|
+
wechat agent_list # 获取应用概况列表
|
442
|
+
wechat batch_job_result [JOB_ID] # 获取异步任务结果
|
443
|
+
wechat batch_replaceparty [BATCH_PARTY_CSV_MEDIA_ID] # 全量覆盖部门
|
444
|
+
wechat batch_replaceuser [BATCH_USER_CSV_MEDIA_ID] # 全量覆盖成员
|
445
|
+
wechat batch_syncuser [SYNC_USER_CSV_MEDIA_ID] # 增量更新成员
|
446
|
+
wechat callbackip # 获取微信服务器IP地址
|
447
|
+
wechat clear_quota # 接口调用次数清零
|
448
|
+
wechat convert_to_openid [USER_ID] # userid转换成openid
|
449
|
+
wechat custom_image [OPENID, IMAGE_PATH] # 发送图片客服消息
|
450
|
+
wechat custom_music [OPENID, THUMBNAIL_PATH, MUSIC_URL] # 发送音乐客服消息
|
451
|
+
wechat custom_news [OPENID, NEWS_YAML_PATH] # 发送图文客服消息
|
452
|
+
wechat custom_text [OPENID, TEXT_MESSAGE] # 发送文字客服消息
|
453
|
+
wechat custom_video [OPENID, VIDEO_PATH] # 发送视频客服消息
|
454
|
+
wechat custom_voice [OPENID, VOICE_PATH] # 发送语音客服消息
|
455
|
+
wechat department [DEPARTMENT_ID] # 获取部门列表
|
456
|
+
wechat department_create [NAME, PARENT_ID] # 创建部门
|
457
|
+
wechat department_delete [DEPARTMENT_ID] # 删除部门
|
458
|
+
wechat department_update [DEPARTMENT_ID, NAME] # 更新部门
|
459
|
+
wechat getusercumulate [BEGIN_DATE, END_DATE] # 获取累计用户数据
|
460
|
+
wechat getusersummary [BEGIN_DATE, END_DATE] # 获取用户增减数据
|
461
|
+
wechat invite_user [USER_ID] # 邀请成员关注
|
462
|
+
wechat material [MEDIA_ID, PATH] # 永久媒体下载
|
463
|
+
wechat material_add [MEDIA_TYPE, PATH] # 永久媒体上传
|
464
|
+
wechat material_count # 获取永久素材总数
|
465
|
+
wechat material_delete [MEDIA_ID] # 删除永久素材
|
466
|
+
wechat material_list [TYPE, OFFSET, COUNT] # 获取永久素材列表
|
467
|
+
wechat media [MEDIA_ID, PATH] # 媒体下载
|
468
|
+
wechat media_create [MEDIA_TYPE, PATH] # 媒体上传
|
469
|
+
wechat media_hq [MEDIA_ID, PATH] # 高清音频媒体下载
|
470
|
+
wechat media_uploadimg [IMAGE_PATH] # 上传图文消息内的图片
|
471
|
+
wechat menu # 当前菜单
|
472
|
+
wechat menu_addconditional [CONDITIONAL_MENU_YAML_PATH] # 创建个性化菜单
|
473
|
+
wechat menu_create [MENU_YAML_PATH] # 创建菜单
|
474
|
+
wechat menu_delconditional [MENU_ID] # 删除个性化菜单
|
475
|
+
wechat menu_delete # 删除菜单
|
476
|
+
wechat menu_trymatch [USER_ID] # 测试个性化菜单匹配结果
|
477
|
+
wechat message_send [OPENID, TEXT_MESSAGE] # 发送文字消息
|
478
|
+
wechat qrcode_download [TICKET, QR_CODE_PIC_PATH] # 通过ticket下载二维码
|
479
|
+
wechat tag [TAG_ID] # 获取标签成员
|
480
|
+
wechat tag_add_department [TAG_ID, PARTY_IDS] # 增加标签部门
|
481
|
+
wechat tag_add_user [TAG_ID, USER_IDS] # 增加标签成员
|
482
|
+
wechat tag_create [TAGNAME, TAG_ID] # 创建标签
|
483
|
+
wechat tag_del_department [TAG_ID, PARTY_IDS] # 删除标签部门
|
484
|
+
wechat tag_del_user [TAG_ID, USER_IDS] # 删除标签成员
|
485
|
+
wechat tag_delete [TAG_ID] # 删除标签
|
486
|
+
wechat tag_update [TAG_ID, TAGNAME] # 更新标签名字
|
487
|
+
wechat tags # 获取所有标签
|
488
|
+
wechat template_message [OPENID, TEMPLATE_YAML_PATH] # 模板消息接口
|
489
|
+
wechat upload_replaceparty [BATCH_PARTY_CSV_PATH] # 上传文件方式全量覆盖部门
|
490
|
+
wechat upload_replaceuser [BATCH_USER_CSV_PATH] # 上传文件方式全量覆盖成员
|
491
|
+
wechat user [OPEN_ID] # 获取用户基本信息
|
492
|
+
wechat user_batchdelete [USER_ID_LIST] # 批量删除成员
|
488
493
|
wechat user_create [USER_ID, NAME] # 创建成员
|
489
|
-
wechat user_delete [USER_ID]
|
490
|
-
wechat user_list [DEPARTMENT_ID]
|
491
|
-
wechat user_simplelist [DEPARTMENT_ID]
|
492
|
-
wechat user_update_remark [OPEN_ID, REMARK]
|
494
|
+
wechat user_delete [USER_ID] # 删除成员
|
495
|
+
wechat user_list [DEPARTMENT_ID] # 获取部门成员详情
|
496
|
+
wechat user_simplelist [DEPARTMENT_ID] # 获取部门成员
|
497
|
+
wechat user_update_remark [OPEN_ID, REMARK] # 设置备注名
|
493
498
|
```
|
494
499
|
|
495
500
|
Note: `replaceparty` full departments uploads only supports a single root node as a department and does not support parallel multiple root nodes.
|
@@ -658,6 +663,16 @@ end
|
|
658
663
|
|
659
664
|
Using `Wechat.api` to access the wechat api function at any place.
|
660
665
|
|
666
|
+
Below is an example via `rails console` to call AI Voice Recognition API:
|
667
|
+
|
668
|
+
```bash
|
669
|
+
# Audio file with ID3 version 2.4.0, contains:MPEG ADTS, layer III, v2, 40 kbps, 16 kHz, Monaural
|
670
|
+
test_voice_file='test_voice.mp3'
|
671
|
+
Wechat.api.addvoicetorecofortext('test_voice_id', File.open(test_voice_file))
|
672
|
+
Wechat.api.queryrecoresultfortext 'test_voice_id'
|
673
|
+
```
|
674
|
+
|
675
|
+
|
661
676
|
## Checking the signature
|
662
677
|
Using `Wechat.decrypt(encrypted_data,session_key, iv)` to decode the data. via. [Signature Checking](https://developers.weixin.qq.com/miniprogram/dev/api/signature.html)
|
663
678
|
|
@@ -745,7 +760,13 @@ class WechatsController < ActionController::Base
|
|
745
760
|
|
746
761
|
# When user sends a voice
|
747
762
|
on :voice do |request|
|
748
|
-
|
763
|
+
# Echo the sent voice to user
|
764
|
+
# request.reply.voice(request[:MediaId])
|
765
|
+
|
766
|
+
voice_id = request[:MediaId]
|
767
|
+
# It's only avaiable for Service Account and enable it in dashboard.
|
768
|
+
recognition = request[:Recognition]
|
769
|
+
request.reply.text "#{voice_id} #{recognition}"
|
749
770
|
end
|
750
771
|
|
751
772
|
# When user sends a video
|
data/bin/wechat
CHANGED
@@ -305,6 +305,16 @@ class App < Thor
|
|
305
305
|
def customservice_getonlinekflist
|
306
306
|
puts wechat_api.customservice_getonlinekflist
|
307
307
|
end
|
308
|
+
|
309
|
+
desc 'addvoicetorecofortext [VOICE_ID]', 'AI开放接口-提交语音'
|
310
|
+
def addvoicetorecofortext(voice_id)
|
311
|
+
puts wechat_api.addvoicetorecofortext(voice_id)
|
312
|
+
end
|
313
|
+
|
314
|
+
desc 'queryrecoresultfortext [VOICE_ID]', 'AI开放接口-获取语音识别结果'
|
315
|
+
def queryrecoresultfortext(voice_id)
|
316
|
+
puts wechat_api.queryrecoresultfortext(voice_id)
|
317
|
+
end
|
308
318
|
end
|
309
319
|
|
310
320
|
desc 'user [OPEN_ID]', '获取用户基本信息'
|
data/lib/wechat/api_base.rb
CHANGED
@@ -2,7 +2,12 @@ module Wechat
|
|
2
2
|
class ApiBase
|
3
3
|
attr_reader :access_token, :client, :jsapi_ticket
|
4
4
|
|
5
|
+
API_BASE = 'https://api.weixin.qq.com/cgi-bin/'.freeze
|
5
6
|
MP_BASE = 'https://mp.weixin.qq.com/cgi-bin/'.freeze
|
7
|
+
WXA_BASE = 'https://api.weixin.qq.com/wxa/'.freeze
|
8
|
+
OAUTH2_BASE = 'https://api.weixin.qq.com/sns/'.freeze
|
9
|
+
DATACUBE_BASE = 'https://api.weixin.qq.com/datacube/'.freeze
|
10
|
+
QYAPI_BASE = 'https://qyapi.weixin.qq.com/cgi-bin/'.freeze
|
6
11
|
|
7
12
|
def callbackip
|
8
13
|
get 'getcallbackip'
|
data/lib/wechat/api_loader.rb
CHANGED
@@ -137,9 +137,10 @@ module Wechat
|
|
137
137
|
end
|
138
138
|
|
139
139
|
private_class_method def self.class_exists?(class_name)
|
140
|
-
|
140
|
+
klass = Module.const_get(class_name)
|
141
|
+
klass.is_a?(Class)
|
141
142
|
rescue NameError
|
142
|
-
|
143
|
+
false
|
143
144
|
end
|
144
145
|
end
|
145
146
|
end
|
@@ -1,13 +1,8 @@
|
|
1
1
|
module Wechat
|
2
2
|
module Concern
|
3
3
|
module Common
|
4
|
-
WXA_BASE = 'https://api.weixin.qq.com/wxa/'.freeze
|
5
|
-
API_BASE = 'https://api.weixin.qq.com/cgi-bin/'.freeze
|
6
|
-
OAUTH2_BASE = 'https://api.weixin.qq.com/sns/'.freeze
|
7
|
-
DATACUBE_BASE = 'https://api.weixin.qq.com/datacube/'.freeze
|
8
|
-
|
9
4
|
def initialize(appid, secret, token_file, timeout, skip_verify_ssl, jsapi_ticket_file)
|
10
|
-
@client = HttpClient.new(API_BASE, timeout, skip_verify_ssl)
|
5
|
+
@client = HttpClient.new(Wechat::Api::API_BASE, timeout, skip_verify_ssl)
|
11
6
|
@access_token = Token::PublicAccessToken.new(@client, appid, secret, token_file)
|
12
7
|
@jsapi_ticket = Ticket::PublicJsapiTicket.new(@client, @access_token, jsapi_ticket_file)
|
13
8
|
end
|
@@ -98,7 +93,11 @@ module Wechat
|
|
98
93
|
end
|
99
94
|
|
100
95
|
def wxa_get_wxacode(path, width = 430)
|
101
|
-
post 'getwxacode', JSON.generate(path: path, width: width), base: WXA_BASE
|
96
|
+
post 'getwxacode', JSON.generate(path: path, width: width), base: Wechat::Api::WXA_BASE
|
97
|
+
end
|
98
|
+
|
99
|
+
def wxa_get_wxacode_unlimit(scene, page = nil, width = 430)
|
100
|
+
post 'getwxacodeunlimit', JSON.generate(scene: scene, page: page, width: width), base: Wechat::Api::WXA_BASE
|
102
101
|
end
|
103
102
|
|
104
103
|
def wxa_create_qrcode(path, width = 430)
|
@@ -188,11 +187,19 @@ module Wechat
|
|
188
187
|
end
|
189
188
|
|
190
189
|
def getusersummary(begin_date, end_date)
|
191
|
-
post 'getusersummary', JSON.generate(begin_date: begin_date, end_date: end_date), base: DATACUBE_BASE
|
190
|
+
post 'getusersummary', JSON.generate(begin_date: begin_date, end_date: end_date), base: Wechat::Api::DATACUBE_BASE
|
192
191
|
end
|
193
192
|
|
194
193
|
def getusercumulate(begin_date, end_date)
|
195
|
-
post 'getusercumulate', JSON.generate(begin_date: begin_date, end_date: end_date), base: DATACUBE_BASE
|
194
|
+
post 'getusercumulate', JSON.generate(begin_date: begin_date, end_date: end_date), base: Wechat::Api::DATACUBE_BASE
|
195
|
+
end
|
196
|
+
|
197
|
+
def addvoicetorecofortext(voice_id, file, file_format = 'mp3', lang = 'zh_CN')
|
198
|
+
post_file 'media/voice/addvoicetorecofortext', file, params: { format: file_format, voice_id: voice_id, lang: lang }
|
199
|
+
end
|
200
|
+
|
201
|
+
def queryrecoresultfortext(voice_id, lang = 'zh_CN')
|
202
|
+
post 'media/voice/queryrecoresultfortext', nil, params: { voice_id: voice_id, lang: lang }
|
196
203
|
end
|
197
204
|
|
198
205
|
def web_access_token(code)
|
@@ -202,11 +209,11 @@ module Wechat
|
|
202
209
|
code: code,
|
203
210
|
grant_type: 'authorization_code'
|
204
211
|
}
|
205
|
-
client.get 'oauth2/access_token', params: params, base: OAUTH2_BASE
|
212
|
+
client.get 'oauth2/access_token', params: params, base: Wechat::Api::OAUTH2_BASE
|
206
213
|
end
|
207
214
|
|
208
215
|
def web_auth_access_token(web_access_token, openid)
|
209
|
-
client.get 'auth', params: { access_token: web_access_token, openid: openid }, base: OAUTH2_BASE
|
216
|
+
client.get 'auth', params: { access_token: web_access_token, openid: openid }, base: Wechat::Api::OAUTH2_BASE
|
210
217
|
end
|
211
218
|
|
212
219
|
def web_refresh_access_token(user_refresh_token)
|
@@ -215,11 +222,11 @@ module Wechat
|
|
215
222
|
grant_type: 'refresh_token',
|
216
223
|
refresh_token: user_refresh_token
|
217
224
|
}
|
218
|
-
client.get 'oauth2/refresh_token', params: params, base: OAUTH2_BASE
|
225
|
+
client.get 'oauth2/refresh_token', params: params, base: Wechat::Api::OAUTH2_BASE
|
219
226
|
end
|
220
227
|
|
221
228
|
def web_userinfo(web_access_token, openid, lang = 'zh_CN')
|
222
|
-
client.get 'userinfo', params: { access_token: web_access_token, openid: openid, lang: lang }, base: OAUTH2_BASE
|
229
|
+
client.get 'userinfo', params: { access_token: web_access_token, openid: openid, lang: lang }, base: Wechat::Api::OAUTH2_BASE
|
223
230
|
end
|
224
231
|
end
|
225
232
|
end
|
data/lib/wechat/corp_api.rb
CHANGED
@@ -7,10 +7,8 @@ module Wechat
|
|
7
7
|
class CorpApi < ApiBase
|
8
8
|
attr_reader :agentid
|
9
9
|
|
10
|
-
API_BASE = 'https://qyapi.weixin.qq.com/cgi-bin/'.freeze
|
11
|
-
|
12
10
|
def initialize(appid, secret, token_file, agentid, timeout, skip_verify_ssl, jsapi_ticket_file)
|
13
|
-
@client = HttpClient.new(
|
11
|
+
@client = HttpClient.new(QYAPI_BASE, timeout, skip_verify_ssl)
|
14
12
|
@access_token = Token::CorpAccessToken.new(@client, appid, secret, token_file)
|
15
13
|
@agentid = agentid
|
16
14
|
@jsapi_ticket = Ticket::CorpJsapiTicket.new(@client, @access_token, jsapi_ticket_file)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wechat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Skinnyworm
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
ivoox98/nhOs6bHcSFPsxXdxUihcCfCzj+zcaHNEqpvTI/36Bnl2XW6dUJNaFQDc
|
36
36
|
oWOyq5ZkxqnYrYXactjW0+vcPv6WHoHXmjv4dF7iFp8r0mvK
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2019-
|
38
|
+
date: 2019-07-02 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: activesupport
|
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
- !ruby/object:Gem::Version
|
215
215
|
version: '0'
|
216
216
|
requirements: []
|
217
|
-
rubygems_version: 3.0.
|
217
|
+
rubygems_version: 3.0.4
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: DSL for wechat message handling and API
|
metadata.gz.sig
CHANGED
Binary file
|