此图片来自微信公众平台未经允许不可引用
<meta name="referrer" content="never">
用PHP模拟浏览器请求
$url = "http://mmbiz.qpic.cn/mmbiz_jpg/6evfQbbmz97sLMeDlTz4RUESzibgNxAtfvIRHsjZeBLql5y1M7IsjbeZBl2KlnMrbNR7c4VpcUJnVw8WJsZRIlw/0";
$ch = curl_init();
$httpheader = array(
'Host' => 'mmbiz.qpic.cn',
'Connection' => 'keep-alive',
'Pragma' => 'no-cache',
'Cache-Control' => 'no-cache',
'Accept' => 'textml,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8',
'User-Agent' => 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36',
'Accept-Encoding' => 'gzip, deflate, sdch',
'Accept-Language' => 'zh-CN,zh;q=0.8,en;q=0.6,zh-TW;q=0.4'
);
$options = array(
CURLOPT_HTTPHEADER => $httpheader,
CURLOPT_URL => $url,
CURLOPT_TIMEOUT => 5,
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array( $ch , $options );
$result = curl_exec( $ch );
curl_close($ch);
header('Content-type: image/jpg');
echo $result;
3.用本地图片和微信图片相互切换使用,显示图片用本地的图片,调用微信素材接口的时候用微信图片
<?php
public function getWxNewsContentImage($content) {
$wx_content = '';
preg_match_all('/<\s*img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $content, $match);
for ($i = 0, $j = count($match['0']); $i < $j; $i++) {
$toggle_image = $this->changeLocal2WxImage($match['2'][$i]);
$wx_content .= str_replace($match['0'][$i], '<img src=' . $toggle_image . '/>', $content);
}
return $wx_content;
}