以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  XP系统报错,WIN7正常  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=149037)

--  作者:ifox2018
--  发布时间:2020/4/21 22:49:00
--  XP系统报错,WIN7正常
 微信发送文本消息报错

内部函数代码:
Static CreateTime As Date \'记录最近一次生成access_token的时间
Static AccessTocken As String \'记录最近一次生成的access_token
Dim CorpID As String=  "wXXXXXXXXX" \'企业号的CorpID
Dim Secret As String = "hynxRXXXXXXXXXXXX" \'管理组的Secret
Dim tp As TimeSpan = Date.Now - CreateTime
If tp.TotalSeconds > 3600 Then
    Dim url As String = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={0}&corpsecret={1}"
    Dim hc As New HttpClient(CExp(url, CorpID, Secret))
    Dim ret As String = hc.GetData()
    If ret = "" Then \'如果失败,再尝试一次
        hc.GetData()
    End If
    CreateTime = Date.Now()
    Dim jo As JObject = JObject.Parse(ret)
    If jo("access_token") IsNot Nothing Then
        AccessTocken = jo("access_token")
    Else
        MessageBox.show("获取access_token失败,原因:" & vbcrlf & jo.ToString)
    End If
End If
Return AccessTocken



click代码


Dim ur As String = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={0}"
Dim hcfg As new HttpClient(Cexp(ur,Functions.Execute("GetQYAccessToken"))) 
Dim jofg As New JObject   \'投诉回复后,推送该投诉的通知信息给分管领导

jofg("toparty") = "12"   \'群发该部门所有人.2fen

jofg("msgtype") = "text"
jofg("agentid") = 1000011
jofg("text") = New JObject


jofg("text")("content") = cstr("[投诉回复通知]:" & e.Form.Controls("车号").value & "来自" & e.Form.Controls("投诉渠道").value &  "渠道的投诉已回复,请查阅." & "   [一分公司  " & Date.NOW & "]" )


hcfg.Content = jofg.ToString
jofg = JObject.Parse(hcfg.GetData)
If jofg("errcode") = "0" Then
    MessageBox.show("回复已发送成功!")
Else
    MessageBox.show(jofg.ToString)
End If

执行后WIN7一切正常。  XP提示出现2个错误弹出

1:  .NET Framework 版本:2.0.50727.3053
Foxtable 版本:2019.4.12.1
错误所在事件:
详细错误信息:
The underlying connection was closed: An unexpected error occurred on a send.
Received an unexpected EOF or 0 bytes from the transport stream.

2:.NET Framework 版本:2.0.50727.3053
Foxtable 版本:2019.4.12.1
错误所在事件:窗口,投诉回复,保存2,Click
详细错误信息:
Error reading JObject from JsonReader. Path \'\', line 0, position 0.
[此贴子已经被作者于2020/4/22 9:41:22编辑过]

--  作者:有点蓝
--  发布时间:2020/4/21 23:11:00
--  
XP不支持https,升级系统吧。或者接口改为http:Dim ur As String = "http://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={0}"
--  作者:ifox2018
--  发布时间:2020/4/22 9:43:00
--  
内部函数那边不用改动。

直接在click代码里  HTTPS  变更为  HTTP?  

这样操作后,XP 报错没变。  WIN7 发送也失败

--  作者:有点蓝
--  发布时间:2020/4/22 9:46:00
--  
首先问问微信官方有没有http的接口?看他们文档应该是没有的,那就只能升级系统了