function actionWechatImg() { header('Content-type: image/jpg'); $url = $_GET['url']; $refer = "http://www.qq.com/"; $opt = [ 'http'=>[ 'header'=>"Referer: " . $refer ] ]; $context = stream_context_create($opt); $file_contents = file_get_contents($url,false, $context); echo $file_contents; }
調用示例:php
<img src="http://xxx.com.cn/wechat-img?url=http%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz%2F5ddyukqqNUt7ic07NicfAz9u0KrHEibKKMiab2cXA2sIqoj81hRsMZC65DCiaN67FsH2WaXkNOEE0YFLj5OHwIOegIg%2F0%3Fwx_fmt%3Djpeg">
微信
其實就是模擬來源站點。url