以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 求助:post传参到微信API获取文章列表报错! (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=92455) |
||||
-- 作者:李孝春 -- 发布时间:2016/11/3 16:39:00 -- 求助:post传参到微信API获取文章列表报错! 代码如下 Dim postdata As String ="{""type"":""news"",""offset"":""0"",""count"":""1""}" Dim url = String.Format("https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=MsxFpyXCWH1Qp5R57uqxChsa6MYvkjyUYkADKWDBjnZNMsARiOdhMsdvXlpnQ0sTa2JNJnnH12CyaXHtBf49uVwrX781Ms4fjYLaAUwJZ5KA-169hn2fyncNnC2T4U5RIQVeAEAPXC") Using ms As New System.IO.MemoryStream() Dim bytes = ConvertHelper.EncodingToBytes(postdata, System.Text.Encoding.UTF8) ms.Write(bytes, 0, bytes.Length) ms.Seek(0, System.IO.SeekOrigin.Begin) Dim jsonString = Functions.Execute("HttpPost",url, ms) \'通过POST向接口传输菜单数据,并取得返回结果 output.show(jsonString ) End Using (在命令窗体运行)错误如下:
相关说明https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738734&token=&lang=zh_CN
|
||||
-- 作者:有点蓝 -- 发布时间:2016/11/3 17:58:00 -- 又是抄作业不抄完整的。 别人有个TimeOut全局变量,定义超时时间,没有定义默认就是0秒,当然超时了 内部函数改为 ...... Dim request As System.Net.HttpWebRequest = DirectCast(System.Net.WebRequest.Create(url), System.Net.HttpWebRequest) request.Method = "POST" request.Timeout = 10000 ......
|
||||
-- 作者:李孝春 -- 发布时间:2016/11/3 20:42:00 -- 回复:(有点蓝)又是抄作业不抄完整的。别人有个Time... Dim postdata As String ="{""type"":""news"",""offset"":""0"",""count"":""2000""}" Dim dr As DataRow =DataTables("ACCESS_TOKEN").Find("公众号名称 = \'黔源科技\'") Dim url = String.Format("https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=" & dr("ACCESSTOKEN") & "") Using ms As New System.IO.MemoryStream() Dim bytes = ConvertHelper.EncodingToBytes(postdata, System.Text.Encoding.UTF8) ms.Write(bytes, 0, bytes.Length) ms.Seek(0, System.IO.SeekOrigin.Begin) Dim jsonString = Functions.Execute("HttpPost",url, ms) \'通过POST向接口传输菜单数据,并取得返回结果 Dim json As String = jsonString Dim ScriptControl As Object, data As Object, JscriptCode As String JscriptCode = "function toObject(json) {eval(""var o=""+json);return o;}" ScriptControl = CreateObject("MSScriptControl.ScriptControl") With ScriptControl .Language = "Javascript" .Timeout = -1 .AddCode(JscriptCode) data = .Run("toObject", json) End With \'output.Show(data.total_count) \'output.Show(data.item_count) \'Dim a As String =data.item(0).content.news_item(0).title \'output.Show("a") output.Show(data.item(0).media_id) output.Show(data.item(0).content.news_item(0).author) output.Show(data.item(0).content.news_item(0).url) output.Show(data.item(0).content.news_item(0).content_source_url) End Using 红色部分代码运行错误如下: josn返回样本如下: 永久图文消息素材列表的响应如下: { "total_count": TOTAL_COUNT, "item_count": ITEM_COUNT, "item": [{ "media_id": MEDIA_ID, "content": { "news_item": [{ "title": TITLE, "thumb_media_id": THUMB_MEDIA_ID, "show_cover_pic": SHOW_COVER_PIC(0 / 1), "author": AUTHOR, "digest": DIGEST, "content": CONTENT, "url": URL, "content_source_url": CONTETN_SOURCE_URL }, //多图文消息会在此处有多篇文章 ] }, "update_time": UPDATE_TIME }, //可能有多个图文消息item结构 ] } [此贴子已经被作者于2016/11/3 20:43:40编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2016/11/3 21:01:00 -- 同样的问题之前问过的,看回自己之前的帖子 |
||||
-- 作者:李孝春 -- 发布时间:2016/11/3 21:16:00 -- 回复:(有点蓝)同样的问题之前问过的,看回自己之前... ok [此贴子已经被作者于2016/11/3 23:57:35编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2016/11/3 23:10:00 -- 有区别吗,多一层和少一层用法都一样 http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=91481
|