Skip to content
php使用socket模拟post、get操作,支持http、socket4、5代理
PHP
Branch: master
Clone or download
Pull request Compare This branch is 1 commit behind weird:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
HttpClient.php
README.md

README.md

GET请求

$http = new HttpClient();
$http->set_header('User-Agent','Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1'); 
$http->get('http://www.example.com/'); 
echo $http->get_body(); 

POST请求

$http = new HttpClient(); 
$http->set_header('User-Agent','Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1'); 
$data = array( 
	'id'=>1, 
	'name'=>'example' 	
); 
$file = array( 
	'photo'=>'/data/patch/file.jpg' 
); 
$http->post('http://www.example.com/',array($data)[,$file]); 
echo $http->get_body(); 

Cookie支持

$http->set_cookies($cookie); 

代理支持

$http->set_proxy('socks5.example.com:1080',HttpClient::PROXY_SOCKS5,'user','password'); 
You can’t perform that action at this time.