MCPcopy
hub / github.com/nodeWechat/wechat4u / sendPic

Method sendPic

src/core.js:633–669  ·  view source on GitHub ↗
(mediaId, to)

Source from the content-addressed store, hash-verified

631 }
632
633 sendPic (mediaId, to) {
634 return Promise.resolve().then(() => {
635 let params = {
636 'pass_ticket': this.PROP.passTicket,
637 'fun': 'async',
638 'f': 'json',
639 'lang': 'zh_CN'
640 }
641 let clientMsgId = getClientMsgId()
642 let data = {
643 'BaseRequest': this.getBaseRequest(),
644 'Scene': 0,
645 'Msg': {
646 'Type': this.CONF.MSGTYPE_IMAGE,
647 'MediaId': mediaId,
648 'FromUserName': this.user.UserName,
649 'ToUserName': to,
650 'LocalID': clientMsgId,
651 'ClientMsgId': clientMsgId
652 }
653 }
654 return this.request({
655 method: 'POST',
656 url: this.CONF.API_webwxsendmsgimg,
657 params: params,
658 data: data
659 }).then(res => {
660 let data = res.data
661 assert.equal(data.BaseResponse.Ret, 0, res)
662 return data
663 })
664 }).catch(err => {
665 debug(err)
666 err.tips = '发送图片失败'
667 throw err
668 })
669 }
670
671 sendVideo (mediaId, to) {
672 return Promise.resolve().then(() => {

Callers 1

sendMsgMethod · 0.80

Calls 2

getBaseRequestMethod · 0.95
getClientMsgIdFunction · 0.90

Tested by

no test coverage detected