获取图片链接: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
///
private bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
}