go语言调用名片识别接口示例

接口地址:http://www.juhe.cn/docs/api/id/139
接口名称:名片识别
package main
import (

   "io/ioutil"
   "encoding/base64"
   "net/url"
   "fmt"
   "net/http"
)


const     (
   URL="http://op.juhe.cn/hanvon/bcard/query"
   KEY="您申请的appKey"
   PATH="D:\\27.jpg"
)


func main(){
   img,_:=ioutil.ReadFile(PATH)
   encoding:=base64.StdEncoding
   image:=encoding.EncodeToString(img)
   v:=url.Values{}
   v.Set("key",KEY)
   v.Set("image",image)

   data,_:=HttpPostForm(URL,v)
   fmt.Println(string(data))
}
func HttpPostForm(url string,v url.Values)(rs[]byte,err error){

   resp,err:=http.PostForm(url,v)
   if err!=nil{
      return nil ,err
   }
   defer resp.Body.Close()
   return ioutil.ReadAll(resp.Body)

}
打印结果:
{
    "reason": "successed",
    "result": {
        "rotatedAngle": null,
        "name": [
            "张敬"
        ],
        "title": [],
        "tel": [
            "0535666777865778886662998"
        ],
        "mobile": [
            "18605358110",
            "13963861177",
            "18605358110"
        ],
        "fax": [
            "05356662998"
        ],
        "email": [
            "ytbddz@163.com"
        ],
        "comp": [
            "邦达电子",
            "云",
            "烟台邦达电子工程有限公司"
        ],
        "dept": [],
        "degree": [],
        "addr": [
            "烟台兴业路34号三站数码广场ffl07号"
        ],
        "post": [],
        "mbox": [],
        "htel": [],
        "web": [
            "www.yt110.net"
        ],
        "im": [],
        "numOther": [
            "Q Q : 1062903877 53977778"
        ],
        "other": [],
        "extTel": []
    },
    "error_code": 0
}


登录 后可发表评论

    最新发布
    聚合数据©版权所有