PHPは単号で宅配便(申通、EMS、順豊、円通、中通、韻達、天天、汇通、全峰、徳邦、宅急送)を検索する.
0,
CURLOPT_URL => $url,
CURLOPT_FRESH_CONNECT => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FORBID_REUSE => 1,
CURLOPT_TIMEOUT => 4,
CURLOPT_POSTFIELDS => http_build_query($post)
);
$ch = curl_init();
curl_setopt_array($ch, ($options + $defaults));
if( ! $result = curl_exec($ch))
{
trigger_error(curl_error($ch));
}
curl_close($ch);
return $result;
}
// JSON
/**
* {"message":"ok","state":"3","data":[{"context":" , 【 】",
* "time":"2013-12-15 11:02:26","ftime":"2013-12-15 11:02:26"},{"context":"
* 【 】 【 82177562 (82171562)】 ",
* "time":"2013-12-14 21:43:38","ftime":"2013-12-14 21:43:38"},{"context":
* " 【 】 【 】 【】","time":"2013-12-14
* 17:19:52","ftime":"2013-12-14 17:19:52"},{"context":" 【 】
* 【 】","time":"2013-12-14 16:26:36","ftime":"2013-12-14 16:26:36"}
* ,{"context":"【 】 【 】 ","time":"2013-12-12 18:59:17",
* "ftime":"2013-12-12 18:59:17"},{"context":" 【 】 【 】"
* ,"time":"2013-12-12 18:59:17","ftime":"2013-12-12 18:59:17"},{"context":"【 】
* 【 】 ","time":"2013-12-12 18:20:47","ftime":"2013-12-12 18:20:47"},
* {"context":"【 】 【 】 ","time":"2013-12-12
* 14:56:21","ftime":"2013-12-12 14:56:21"}],"status":"200","com":"shentong","nu":
* "768064369802","condition":"F00","ischeck":"1"}
*/
// JSON
/**
* {"message":"ok","state":"3",
* "data":[{"context":" :
* : ","time":"2013-12-17 15:42:00",
* "ftime":"2013-12-17 15:42:00"},{"context":" : ",
* "time":"2013-12-17 09:47:00","ftime":"2013-12-17 09:47:00"}
* ,{"context":" : , ",
* "time":"2013-12-16 18:38:56","ftime":"2013-12-16 18:38:56"},
* {"context":" : , ","time":"
* 2013-12-16 17:27:18","ftime":"2013-12-16 17:27:18"},{"context":
* " : , ","time":"2013-12-14 23:57:43","ftime":
* "2013-12-14 23:57:43"},{"context":" : , ",
* "time":"2013-12-14 22:51:02","ftime":"2013-12-14 22:51:02"},
* {"context":" : ","time":"2013-12-14 15:00:00",
* "ftime":"2013-12-14 15:00:00"}],"status":"200","com":"ems","nu":"5000655082802",
* "condition":"F00","ischeck":"1"}
*/
// JSON
/**
* {"status":"201","message":" : "}
*/
/**
* @param string $postid
* @param string $type
* shentong --->
* ems ---> EMS
* shunfeng -->
* yuantong -->
* zhongtong -->
* yunda -->
* tiantian --->
* huitongkuaidi -->
* quanfengkuaidi -->
* debangwuliu -->
* zhaijisong -->
* @return mixed json
*/
function Dquery($postid = "268323324324" , $type = "shentong")
{
$post_data = array (
"type" => $type,
"postid" => $postid ,
"id" => "1",
"valicode" => "",
"temp" => "0.7771608149632812"
) ;
$url ='http://www.kuaidi100.com/query';
return curl_get($url,$post_data);
}
/**
*
* @param string $postid String
* @return mixed at most json
*/
function shentong($postid = "768064369802")
{
return Dquery($postid,"shentong");
}
/**
* EMS
* @param string $postid
* @return mixed JSON
*/
function EMS($postid = "5000655082802")
{
return Dquery($postid,"ems");
}
/**
*
* @param string $postid
* @return mixed JSON
*/
function shunfeng($postid = "370270606236")
{
return Dquery($postid,"shunfeng");
}
/**
*
* @param string $postid
* @return mixed JSON
*/
function yuantong($postid = "9149223354")
{
return Dquery($postid,"yuantong");
}
/**
*
* @param string $postid
* @return mixed JSON
*/
function zhongtong($postid = "778179380478")
{
return Dquery($postid,"zhongtong");
}
/**
*
* @param string $postid
* @return mixed JSON
*/
function yunda($postid = "1201030121554")
{
return Dquery($postid,"yunda");
}
/**
*
* @param string $postid
* @return mixed JSON
*/
function tiantian($postid = "580054419316")
{
return Dquery($postid,"tiantian");
}
/**
*
* @param string $postid
* @return mixed JSON
*/
function huitongkuaidi($postid="210322948150")
{
return Dquery($postid,"huitongkuaidi");
}
/**
*
* @param string $postid
* @return mixed JSON
*/
function quanfengkuaidi($postid="340003662547")
{
return Dquery($postid,"quanfengkuaidi");
}
/**
*
* @param string $postid
* @return mixed JSON
*/
function debangwuliu($postid="16312048")
{
return Dquery($postid,"debangwuliu");
}
/**
*
* @param string $postid
* @return mixed JSON
*/
function chaijisong($postid = "3332776112")
{
return Dquery($postid,"zhaijisong");
}
//Debug debug, 。
// json 。。
//print_r(json_decode(shentong()));
//echo EMS();
//echo shunfeng();
//echo yuantong();
//echo zhongtong();
//echo yunda();
//echo tiantian();
//echo huitongkuaidi();
//echo quanfengkuaidi();
//echo debangwuliu();
?>
何も言うことはない==注釈が詳しくなった.
あら、私が書いたコードですが.しかし、そのために使う経済トラブルなどは私を探さないでください!!!
転載は出典を明記してくださいhttp://hlyblog.net/?p=86
あるいはcsdn ipqhjjybjからのブログを明記します