引用公众号的图片无法正确显示
引用公众号的图片提示 “此图片来自微信公众平台未经允许不可引用”
解决办法:
# 使用后端中转
<img src="{:url('showImage', {type: '...url...'})}" />
public function showImage(){
$url = $this->request->get('url');
header('content_type:image/jpeg');
echo getCurl($url);
}
function getCurl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$result = curl_exec($ch);
curl_close ($ch);
return $result;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
上次更新: 2023/09/22, 16:54:32