In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is to share with you the content of a sample analysis of the development of a third-party management tool for public accounts on Wechat for php. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The details are as follows:
Recently, we have been messing with the API provided by Wechat's public platform, and so on, it is really an API to get user information.
So there is no way, can only get their own, manually fill in of course can solve the problem, of course, programming is not to make life easier?
Of course, the idea of remotely crawling data from Wechat's public platform arises, and of course CURL is the first one to think of it.
CURL can submit expressions remotely. I think Wechat suggests us how, as long as it is not malicious to browse the interface, there will be no CAPTCHA.
Several main issues to be paid attention to:
The ① remote login interface is the time for HTTPS protocol.
The page is redirected after a successful login to ②.
The HTML page returned by ③ can be output directly.
The following shows a specific way to write CURL
/ / Wechat remote login bind account public function Curl_login ($username,$pwd) {$config_token = "XiaoDengPHP"; $pwd= md5 ($pwd); $url = "https://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN"; $postArray = array (" username= ". $username," pwd= ". $pwd," imgcode= "," f=json "); $fields = implode (" & ", $postArray); $filedir = $_ SERVER ['DOCUMENT_ROOT']." / Cookies " $cookie_file = $filedir. "/ cookie.txt"; $ch = curl_init (); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 1); / / indicates that the https protocol submission curl_setopt ($ch, CURLOPT_HEADER, 0); / / does not return header part curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0) Windows NT 5.0) "); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, $fields); curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie_file); / / produce Cookies and save curl_setopt ($ch, CURLOPT_RETURNTRANSFER,1) in the specified directory; / / return the information obtained by curl_exec () as a file stream instead of directly outputting it. Curl_setopt ($ch, CURLOPT_REFERER, "https://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN"); / / Jump points to $result = curl_exec ($ch); return json_decode ($result); / / closes CURL session curl_close ($ch);}
The above method is implemented, remotely log in to the Wechat public platform, and the next thing is to turn the account into developer mode, the same CURL.
Note that this time the curl should bring cookies instead of production cookies
The key code is to verify the corresponding server. You need to set up a connection to the server and a token.
Public function auth ($token) {$data = array ($_ GET ['timestamp'], $_ GET [' nonce'], $token); $sign = $_ GET ['signature']; sort ($data); $signature = sha1 (implode ($data)); if ($signature = = $sign) {echo ($GET [' echostr']); exit;} else {return false;}}
In this way, if the activation is successful, a json data of MES=302 and a token verified by Wechat platform should be returned.
As long as you are careful, you will find that the TOKEN in Wechat connections is a dynamic change, but some remain unchanged for a period of time.
So you need this token to construct URL to get other page information.
But in the process of development, you must encounter a very collapsing problem.
Thank you for reading! This is the end of the article on "sample analysis of the development of third-party management tools for public accounts on Wechat for php". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.