{"id":2123,"date":"2025-08-27T23:01:52","date_gmt":"2025-08-27T15:01:52","guid":{"rendered":"https:\/\/www.fanyamin.com\/wordpress\/?p=2123"},"modified":"2025-08-27T23:01:52","modified_gmt":"2025-08-27T15:01:52","slug":"%e8%ae%af%e9%a3%9e%e5%bc%80%e6%94%be%e5%b9%b3%e5%8f%b0api","status":"publish","type":"post","link":"https:\/\/www.fanyamin.com\/wordpress\/?p=2123","title":{"rendered":"\u8baf\u98de\u5f00\u653e\u5e73\u53f0API"},"content":{"rendered":"<p><a href=\"https:\/\/www.xfyun.cn\/doc\/asr\/voicedictation\/API.html#%E6%8E%A5%E5%8F%A3%E8%B0%83%E7%94%A8%E6%B5%81%E7%A8%8B\">https:\/\/www.xfyun.cn\/doc\/asr\/voicedictation\/API.html#%E6%8E%A5%E5%8F%A3%E8%B0%83%E7%94%A8%E6%B5%81%E7%A8%8B<\/a><\/p>\n<pre><code class=\"language-golang\">\/\/@hosturl :  like  wss:\/\/iat-api.xfyun.cn\/v2\/iat\n    \/\/@apikey : apiKey\n    \/\/@apiSecret : apiSecret\n    func assembleAuthUrl(hosturl string, apiKey, apiSecret string) string {\n        ul, err := url.Parse(hosturl)\n        if err != nil {\n            fmt.Println(err)\n        }\n        \/\/\u7b7e\u540d\u65f6\u95f4\n        date := time.Now().UTC().Format(time.RFC1123)\n        \/\/\u53c2\u4e0e\u7b7e\u540d\u7684\u5b57\u6bb5 host ,date, request-line\n        signString := []string{&quot;host: &quot; + ul.Host, &quot;date: &quot; + date, &quot;GET &quot; + ul.Path + &quot; HTTP\/1.1&quot;}\n        \/\/\u62fc\u63a5\u7b7e\u540d\u5b57\u7b26\u4e32\n        sgin := strings.Join(signString, &quot;\\n&quot;)\n        \/\/\u7b7e\u540d\u7ed3\u679c\n        sha := HmacWithShaTobase64(&quot;hmac-sha256&quot;, sgin, apiSecret)\n        \/\/\u6784\u5efa\u8bf7\u6c42\u53c2\u6570 \u6b64\u65f6\u4e0d\u9700\u8981urlencoding\n        authUrl := fmt.Sprintf(&quot;api_key=\\&quot;%s\\&quot;, algorithm=\\&quot;%s\\&quot;, headers=\\&quot;%s\\&quot;, signature=\\&quot;%s\\&quot;&quot;, apiKey,\n            &quot;hmac-sha256&quot;, &quot;host date request-line&quot;, sha)\n        \/\/\u5c06\u8bf7\u6c42\u53c2\u6570\u4f7f\u7528base64\u7f16\u7801\n        authorization:= base64.StdEncoding.EncodeToString([]byte(authUrl))\n        v := url.Values{}\n        v.Add(&quot;host&quot;, ul.Host)\n        v.Add(&quot;date&quot;, date)\n        v.Add(&quot;authorization&quot;, authorization)\n        \/\/\u5c06\u7f16\u7801\u540e\u7684\u5b57\u7b26\u4e32url encode\u540e\u6dfb\u52a0\u5230url\u540e\u9762\n        callurl := hosturl + &quot;?&quot; + v.Encode()\n        return callurl\n    }\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/www.xfyun.cn\/doc\/asr\/voicedictation\/API.html#%E6%8E%A5%E5%8F%A3%E8%B0%83%E7%94%A8%E6%B5%81%E7%A8%8B \/\/@hosturl : like wss:\/\/iat-api.xfyun.cn\/v2\/iat \/\/@apikey : apiKey \/\/@apiSecret : apiSecret func assembleAuthUrl(hosturl string, apiKey, apiSecret string) string { ul, err := url.Parse(hosturl) if err != nil { fmt.Println(err) } \/\/\u7b7e\u540d\u65f6\u95f4 date := time.Now().UTC().Format(time.RFC1123) \/\/\u53c2\u4e0e\u7b7e\u540d\u7684\u5b57\u6bb5 host ,date, request-line signString := []string{&quot;host: &quot; + ul.Host, &quot;date: &quot; + date, &quot;GET &quot; + ul.Path + &quot; HTTP\/1.1&quot;} [&hellip;] <a class=\"read-more\" href=\"https:\/\/www.fanyamin.com\/wordpress\/?p=2123\" title=\"Permanent Link to: \u8baf\u98de\u5f00\u653e\u5e73\u53f0API\">&rarr;Read&nbsp;more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-2123","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2123"}],"collection":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2123"}],"version-history":[{"count":1,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2123\/revisions"}],"predecessor-version":[{"id":2124,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2123\/revisions\/2124"}],"wp:attachment":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}