以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 求助一段关于微信接口的代码 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=164312) |
-- 作者:czy66ds -- 发布时间:2021/5/6 10:09:00 -- 求助一段关于微信接口的代码 对于微信接口,官方提供了一系列代码,比如用户接口, 只要修改部分信息,就可以拿来就用。带来极大方便。 用户关注了我的公众号后, 就可以激活一个“会员卡“,内容包括卡号,姓名,手机,性别和生日。 能不能帮我写一段代码,使得我在狐表中, 通过扫码客户的会员卡号,就可以获得该会员的姓名,手机,性别和生日的数据呢?
|
-- 作者:有点蓝 -- 发布时间:2021/5/6 10:45:00 -- Dim url As String = "https://api.weixin.qq.com/card/membercard/userinfo/get?access_token={0}" url = CExp(url, Functions.Execute("GetAccessToken")) Dim hc As New HttpClient(url) Dim jo As New JObject() jo("card_id") = "pbLatjtZ7v1BG_ZnTjbW85GYc_E8" jo("code") = "916679873278" hc.Content = jo.ToString() dim ret as string = hc.GetDaTa msgbox(ret) Dim jo As JObject = Jobject.Parse(ret) If jo("errcode").tostring = "0" Then
MessageBox.Show("设置用户备注名成功") Else MessageBox.Show(jo.ToString) End If |
-- 作者:czy66ds -- 发布时间:2021/5/6 13:31:00 -- 谢谢 那么,如何像“获取单个用户信息”代码 Dim url As String = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang=zh_CN" url = CExp(url, Functions.Execute("GetAccessToken"), "ojDlHuAjZ8Z3eSm0gW1g0Lxbz54s") Dim hc As New HttpClient(url) Dim jo As JObject = Jobject.Parse(hc.GetDaTa) If jo("errcode") Is Nothing Then Dim dr As DataRow = DataTables("WXUsers").AddNew() Dim nms() As String = {"openid","nickname","sex","city","country","province","headimgurl","groupid","remark","language"} For Each nm As String In nms dr(nm) = jo(nm) Next If jo("tagid_list") IsNot Nothing Then dr("tagid_list") = CompressJson(jo("tagid_list")).Trim("[","]") End If dr.Save() Else MessageBox.Show(jo.ToString) End If 这样获取会员卡信息呢?
|
-- 作者:有点蓝 -- 发布时间:2021/5/6 13:59:00 -- 用法一样,自己看官方帮助看返回的json有什么字段属性:https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Membership_Cards/Manage_Member_Card.html |