This article mainly introduces how PHP obtains QQ information from QQ talents. The example analyzes the principles and implementation skills of php to obtain QQ information, which has some reference value, for more information, see the following example. Share it with you for your reference. The specific analysis is as follows:
Add the following:
① This is a simple routine. through expansion, you can easily obtain tens of millions of QQ information. The $ jsonUrl parameter cd = 610900 is the city code.
② QQ Daren information has been done anti-Leech, so the use of PHP refer to forge http://city.qq.com
③ I wanted to create a QQ mail group program, but it had no economic value. it was very easy to contribute to your reference.
The code is as follows:
The code is as follows:
<? Php
$ Refer = "http://city.qq.com"; // defines $ refer
$ Opt = array ('http' => array ('header' => "Referer: $ refer"); // an array of request headers
$ Context = stream_context_create ($ opt); // create a message text sending context header
$ JsonUrl = "http://city.qq.com/json.php? Mod = search & act = page & callback = showSrchResult & jsontype = str & perpage = 10 & cd = 610900 & nl = 3 & xb = 0 & type = city & pg = 1";
$ JsonStr = getJson ($ jsonUrl, $ refer, $ context); // call the JSON proxy function
Echo $ jsonStr; // output JSON text
// Obtain the JSON data of QQ talents
Function getJson ($ url, $ referer, $ context)
{
$ Opt = array ('http' => array ('header' => "Referer: $ referer "));
$ Context = stream_context_create ($ opt );
$ GetJsonStr = file_get_contents ($ url, false, $ context );
$ GetJsonStr = substr ($ getJsonStr, 0,-2 );
$ GetJsonStr = substr ($ getJsonStr, 15 );
Return $ getJsonStr;
}
?>
I hope this article will help you with php programming.