本帖最后由 for_flr 于 2021-12-14 14:30 编辑
也可以用这种方式- 作者@zaqmlp
- Add-Type -AssemblyName System.Web;
- $url='https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic';
- $pic='C:\Users\Administrator\Desktop\test.jpg';
- $imagedata=[Web.HttpUtility]::UrlEncode([Convert]::ToBase64String([IO.File]::ReadAllBytes($pic)));
- $poststr=@( 'access_token=24.b305c9822131e65eda05e29c157dd719.2592000.1559103982.282335-16139329',
- $('image='+$imagedata),
- 'language_type=CHN_ENG',
- 'detect_direction=false',
- 'detect_language=false',
- 'probability=false'
- ) -join '&';
- $web=New-Object System.Net.WebClient;
- $web.Headers.Add('Content-Type', 'application/x-www-form-urlencoded');
- [byte[]]$postdata=[Text.Encoding]::UTF8.GetBytes($poststr);
- [byte[]]$responsedata=$web.UploadData($url, 'POST', $postdata);
- [Text.Encoding]::UTF8.GetString($responsedata);
复制代码 在这里看到的 http://www.bathome.net/viewthrea ... p;extra=&page=2
其中,access_token有效期30天,用以下方式返回
curl -i -k 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=【百度云应用的AK】&client_secret=【百度云应用的SK】' |