Php public account third-party management tool development concise tutorial, php concise tutorial
This article describes how to develop a third-party management tool for php public accounts. We will share this with you for your reference. The details are as follows:
Recently, the APIS provided on the public platform of the dump bucket are indeed an API for Obtaining user information.
So there is no way, you can only get it by yourself. manual filling can solve the problem, of course, isn't programming just to make life easier?
Of course, the idea of remotely capturing data on the public platform was born, and of course the first thought was CURL.
CURL can be submitted remotely. I feel like it is a proposal. As long as it is not a malicious interface, no verification code will appear.
Several important issues:
① The remote logon interface is the HTTPS protocol.
② After Successful Logon, the page jumps.
③ The returned HTML page can be output directly.
The following describes how to write a CURL.
// Remote login bound 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, expires, 1); // indicates that curl_setopt ($ ch, CURLOPT_HEA DER, 0); // 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 ); // generate Cookies and save them in the specified directory. curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); // return the information obtained by curl_exec () in the form of 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 to $ result = curl_exec ($ ch); return json_decode ($ result); // close CURL session curl_close ($ ch );}
The above method is implemented, remotely logging on to the public platform, the next thing is to change the account to the developer mode, the same CURL.
Note that this curl requires cookies instead of cookies.
The key code is to verify the server. You need to set a server connection 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 service is successfully activated, a message of MES = 302 json data and a platform-certified token will be returned.
As long as you are careful, you will find that the TOKEN in the connection changes dynamically, but it remains unchanged for a period of time.
Therefore, you need this token to construct a URL to obtain other page information.
However, you must have encountered a very bad problem during the discovery process.