In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
How to solve the Wechat article picture hotlink protection problem, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
Wechat provides an API interface to allow us to obtain articles in our official account by authorization, or you can crawl Wechat articles through crawlers, but Wechat images are not allowed to be called from outside by default.
Here I found two options.
First kind
Load the picture locally in advance in JS, and then read the picture from the local cache
Var showImg = function (url) {var frameid = 'frameimg' + Math.random (); window.img ='
_ window.onload = function () {parent.document.getElementById (\'+ frameid +'\'). Height = document.getElementById (\ 'img\') .height +\'px\';}'; return';}
The second kind
Simulate browser requests with PHP
$url = $request- > input ('url'); $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;exit
The two methods are similar, I am currently using the JS method, which has been tested and can be used
After reading the above, do you know how to solve the problem of hotlink protection in Wechat articles? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.