微信公眾號獲取圖片時報錯43003


獲取圖片鏈接:http://file.api.weixin.qq.com/cgi-bin/media/get?access_token={0}&media_id={1}
如今會提示錯誤{"errcode":43003,"errmsg":"require https hints: [vkjeLhqge-92sgla!] Please View: [https://w.url.cn/s/ApJ0Ci4] "},如下圖:

解決辦法:把http改為https
把獲取圖片鏈接改為:https://file.api.weixin.qq.com/cgi-bin/media/get?access_token={0}&media_id={1}
測試過后下載成功

把http改為https后,C#代碼用WebClient請求https頁面會出錯:基礎連接已經關閉: 未能為 SSL/TLS 安全通道建立信任關系。
解決辦法:
創建WebClient前加上下面這句,使用回調的方法進行證書驗證。
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);

///


/// 回調驗證證書問題
///

/// 流對象
/// 證書
/// X509Chain
/// SslPolicyErrors
/// bool
private bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM