以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]阿里云身份证API问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=130392)

--  作者:智友软件工作室
--  发布时间:2019/1/21 1:10:00
--  [求助]阿里云身份证API问题
阿里云身份证图片识别API地址:
https://market.aliyun.com/products/57124001/cmapi010401.html?spm=5176.2020520132.101.3.324f7218EL9YPC#sku=yuncode440100000

我写的代码如下:
Dim AppKey As String = ""
Dim  AppSecret As String = ""
Dim AppCode As String = ""
\'Dim hc As New HttpClient("http://ali-deliver.showapi.com/showapi_expInfo?com=shunfeng&nu=929601675231")
\'Dim hc As New HttpClient("http://dm-51.data.aliyun.com/rest/160601/ocr/ocr_idcard.json?com=shunfeng&nu=929601675231")


\'hc.Headers.Add("Authorization","APPCODE " & "7858a126750949e4a36371580f420413")

\'制作本地图片的base64串
Dim bendilujing As String
Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog
dlg.Filter= "图形文件|*.bmp;*.jpg;*.jpeg;*.png"
If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮
Else
    Return Nothing
End If
bendilujing = dlg.FileName
\'MessageBox.Show(bendilujing)
Dim bmp As new Bitmap(bendilujing)
Dim ms As new System.Io.MemoryStream()
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim arr(ms.Length) As Byte
ms.Position = 0
ms.Read(arr, 0, ms.Length)
ms.Close()
Dim strbaser64 As String = Convert.ToBase64String(arr)
bmp.dispose
\'msgbox("读取数据完毕")
\'制作json
Dim jo As New JObject
jo("image") = strbaser64

\'jo("configure") = "{\\"side\\":\\"face\\"}"
jo("configure") = New JObject
jo("configure")("face") = "face"
msgbox("读取数据完毕")
\'msgbox(jo.ToString)
Dim hc As New HttpClient("http://dm-51.data.aliyun.com/rest/160601/ocr/ocr_idcard.json")

hc.Headers.Add("Authorization","APPCODE " & AppCode)
hc.Content = jo.ToString
jo = Jobject.Parse(hc.GetData)
msgbox(jo("name"))




Return Nothing


结果显示错误464

确实不会,尝试很多次,里面有很多地方不明白,请教了,万分感谢
[此贴子已经被作者于2019/1/21 1:14:55编辑过]

--  作者:有点甜
--  发布时间:2019/1/21 9:41:00
--  

参考

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=104710&replyID=717200&skin=1