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
红色部分代码运行错误如下:
此主题相关图片如下:11.png
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编辑过]