phpʵÏÖÄ£ÄâpostÇëÇóÓ÷¨ÊµÀý

ʱ¼ä£º2016.04.20 ·¢²¼ÈË£ºpntkd94771

phpʵÏÖÄ£ÄâpostÇëÇóÓ÷¨ÊµÀý

Òѽâ¾öÎÊÌâ

¹È¸èpntkd94771Óû§ÔÚ2016.04.20Ìá½»Á˹ØÓÚ¡°¹Ê¹¬²©Îï¹ÝphpʵÏÖÄ£ÄâpostÇëÇóÓ÷¨ÊµÀý¡±µÄÌáÎÊ£¬»¶Ó­´ó¼ÒÓ¿Ô¾·¢±í×Ô¼ºµÄ¹Ûµã¡£Ä¿Ç°¹²ÓÐ1¸ö»Ø´ð£¬×îºó¸üÐÂÓÚ2024-12-24T22:21:12¡£Ï£Íû´ó¼ÒÄܹ»°ïÖúËý¡£

ÏêϸÎÊÌâÃèÊö¼°ÒÉÎÊ£ºÆÚ´ýÄúµÄ´ð°¸£¬Ï£ÍûÄãÄܸÐÊܵ½,ÎÒ×îÕæ³ÏµÄлÒâ £¡

Ï£ÍûÒÔϵĻشð£¬Äܹ»°ïÖúÄã¡£

µÚ1¸ö»Ø´ð

Óû§Ãû£ºtand¼Ü¸üµÄÂýÇéÈÎafeng22  

±¾ÎÄʵÀý½²ÊöÁËphpʵÏÖÄ£ÄâpostÇëÇóµÄ·½·¨¡£·ÖÏí¸ø´ó¼Ò¹©´ó¼Ò²Î¿¼¡£¾ßÌåÈçÏ£º

classRequest{publicstaticfunctionpost($url,$post_data='',$timeout=5){//curl$ch=curl_init();curl_setopt·þ($ch,CURLOPT_URL,$url);curl_setopt($ch,CURLOPT_POST,1ÎÊ´ð);if($post_data!=''){curl´¨¶øÐÞ½¥Éù´Ó¼Ò»ú¾²_setopt($c»ý»ñËü¿íh,CURLOPT_POSTÇú¿öÒéͼ»¬Á÷FIELDS,$post_data);}curl_seto´ÅÍű±Ðëpt($ch,CURLÕÅѽµ÷Ðíµ¹Ëµ´ï³¡OPT_RETURNTRANSFER,1);curl_setopt($ch,ÐĹ¹ÀýCURLOPT_CONNС֧²âÕÅÆß¶øÖÆÀàÅÂECTTIMEOUT,$timeout);curl_setopt($ch,CURLOPT_h**EADER,faÊ«Åɳ¤±íÀàÊÕ»»¸úÃñlse);$file_contents=curl_exec($ch);curl_close($ch);return$file_contents;}publicstaticfunctionpost2($url,$data=array()){//file_get_content$postdata=http_build_ÓÉÌýquery($data);$opts=array('http'=>array('method'=>'POST','header'=>'Content-type:application/x-www-form-urlencod¶ËÖÚ·ÇÀ¼ÒÒË«³ª»µÀ´ÇÒed','content'=>$postdata±ø²¢¼°À©ËÙÑø¼¤¾«Í¨Æó));$context=stream_context_create($opts);$result=file_get_contents($url,false,$context);return$result;}publicstaticfunctionpost3($host,$path,$query,$others=''){//fsocket$post="POST$pathh**TTP/1.1\r\nh**ost:$host\r\n";$post.="Content-type:application/x-www-form-";$post.="urlencoded\r\n${otheÇú±±¸Ï×örs}";$post.="User-Agent:Mozilla4.0\r\nContent-length:";$post.=strlen($query)."\r\nConnection:close\r\n\r\ÕÕÈçÈçί²¢n$query";$h=fsockopen($host,80);fwrite($h,$post);for($a=0,$r='';!$a;){$b=fread($h,8192);$r.=$b;$a=(($b=='')?1:0);}fclose($h);return$r;}}$url='http://******/coÑéÏàËï¶ø³ä³åÀë¾än/Inter.php';$data=Request::post($url,array('api'=>'tag_list'))Ê**éÈÈijԸ½×¹ËÓÃ;$data2=Request::post2($url,array('api'=>'tag_list'));echo$ÇòÎÞÇåÄÃÊÇ»³Ó¢ËÙdata;

Ï£Íû±¾ÎÄËùÊö¶Ô´ó¼ÒµÄphp³ÌÐòÉè¼ÆÓÐËù°ïÖú¡£