如何用PHP编写模拟长尾词的POST请求代码?
- 内容介绍
- 文章标签
- 相关推荐
本文共计121个文字,预计阅读时间需要1分钟。
phpclass Request { public static function post($url, $post_data='', $timeout=5) { $ch=curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); if ($post_data !=='') { curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); } curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response=curl_exec($ch); curl_close($ch); return $response; }}
class Request{ public static function post($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($ch, CURLOPT_POSTFIELDS, $post_data); } curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_HEADER, false); $file_contents = curl_exec($ch); curl_close($ch); return $file_contents; } public static function post2($url, $data=array()){//file_get_content $postdata = ******/con/Inter.php'; $data=Request::post($url,array('api'=>'tag_list')); $data2=Request::post2($url,array('api'=>'tag_list')); echo $data;
本文共计121个文字,预计阅读时间需要1分钟。
phpclass Request { public static function post($url, $post_data='', $timeout=5) { $ch=curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); if ($post_data !=='') { curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); } curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response=curl_exec($ch); curl_close($ch); return $response; }}
class Request{ public static function post($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($ch, CURLOPT_POSTFIELDS, $post_data); } curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_HEADER, false); $file_contents = curl_exec($ch); curl_close($ch); return $file_contents; } public static function post2($url, $data=array()){//file_get_content $postdata = ******/con/Inter.php'; $data=Request::post($url,array('api'=>'tag_list')); $data2=Request::post2($url,array('api'=>'tag_list')); echo $data;

