GET:
$htmlsource =file_get_contents ("Http://192.168.0.13/s/interface/shangpin/shangpinDL");
$postArray = Iconv ("Utf-8", "GBK", $htmlsource);
$postArray = Iconv ("GBK", "Utf-8", $postArray);
Echo $postArray;
$de _json = Json_decode ($postArray, TRUE);
echo $de _json;
Echo var_dump ($de _json);
$count _json = count ($de _json);
echo $count _json;
for ($i = 0; $i < $count _json; $i + +)
{
Echo var_dump ($de _json);
$dt _id = $de _json[$i] [' id '];
$dt _pname = $de _json[$i] [' pname '];
echo $dt _id. " >>>> ". $dt _pname;
}
JSON parsing
$postArray = ' [{' data ': {' hello ': ' World '}, ' type ': ' 1234 ', ' Date ': ' 2012-10-30 17:6:9 ', ' user ': ' 000000000000000 ', ' time_ Stamp ": 1351587969902}, {" Data ": {" Hello ":" World "}," type ":" 1234 "," date ":" 2012-10-30 17:12:53 "," User ":" 000000000000000 "," Time_stamp ": 1351588373519}] ';
$de _json = Json_decode ($postArray, TRUE);
$count _json = count ($de _json);
echo $count _json;
for ($i = 0; $i < $count _json; $i + +)
{
$dt _record = $de _json[$i] [' Date '];
$data _type = $de _json[$i] [' type '];
$imei = $de _json[$i] [' User '];
$message = Json_encode ($de _json[$i] [' data ']);
echo $data _type. " >>>> ". $imei." <br/> ";
}
Post:curl
Dump (Ppost ("Http://localhost:8080/thinkox/index.php?s=/home/user/login", $shuzu));//This is the call statement $shuzu is the argument
function Ppost ($url, $arr) {
$post _data = $arr;
$url = $url;
$o = "";
foreach ($post _data as $k = $v)
{
$o. = "$k =". UrlEncode ($v). " & ";
}
$post _data=substr ($o, 0,-1);
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_post, 1);
curl_setopt ($ch, Curlopt_header, 0);
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, curlopt_returntransfer,1);//This is also the setting for whether to receive the return value
To support cookies
curl_setopt ($ch, Curlopt_cookiejar, ' cookie.txt ');
curl_setopt ($ch, Curlopt_postfields, $post _data);
$result = curl_exec ($ch);
return $result;
}
PHP Network programming