Foxtable(狐表)用户栏目专家坐堂 → 关于简单的微信的客服系统


  共有2725人关注过本帖平板打印复制链接

主题:关于简单的微信的客服系统

帅哥,在线噢!
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106305 积分:540660 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/4/24 16:25:00 [只看该作者]

请提出具体的问题!改起来什么地方有问题?

比如服务端接收聊天窗口信息后,wechatReceivedMessage事件:

'处理接收到客户端的消息,然后转发到指定用户微信'
Dim userid = e.WeChatID
If e.ContentType = 0 Then '本例子只处理文本消息
    Dim drUser As DataRow = DataTables("微信用户").Find(CExp("[_Identify]={0} ",userid))
    If drUser IsNot Nothing Then
        Dim text = WeChat.SendMessageHelper.GetSendMessage(WeChat.ApiType.MP, "text") 

        text.touser = drUser("OpenID")
        text.AddContent(e.Content)
        Dim weRet = WeChat.WeChatServer.Server(Vars("mpappid")).SendMsgController.SendMessage(text.ToJson(True)) '发送消息到微信
        If not weRet.Success Then
            Functions.Execute("logText",weRet.ErrorMessage & "|" & text.ToJson(True))
        End If
        
    End If
End If

改为

Dim userid = e.WeChatID
If e.ContentType = 0 Then '本例子只处理文本消息
    Dim drUser As DataRow = DataTables("微信用户").Find(CExp("[_Identify]={0} ",userid))
    If drUser IsNot Nothing Then
        Dim jo As New JObject
        jo("touser") = drUser("OpenID")
        jo("msgtype") = "text"
        jo("text") =  New JObject
        jo("text")("content") = e.Content
        
        Dim URL As String = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}"
        Dim hc As New HttpClient(CExp(URL, Functions.Execute("GetAccessToken")))
        hc.Content = jo.ToString()
        jo = JObject.Parse(hc.GetData())
        If jo("errcode") <> "0" Then
            Functions.Execute("logText",jo("errmsg") & "|" & text.ToJson(True))
        End If
        
    End If
End If

 回到顶部
总数 20 1 2 下一页