curlpp是一個方便在php中發起http請求的C++擴充。基於libcurl開發。有別於已有的curl擴充。curlpp提供的介面更加簡明,輕鬆發起GET/POST請求.
curlpp的主要特點是告別麻煩的設定過程,直面業務本身,在保證效能的前提下,加速開發和運行效率。
class curlpp { public function set_proxy($host, $port); public function set_proxy_credentials($username, $password); public function set_auto_redirect($tf); public function set_timeout($time); public function set_head($head); public function set_cookie($cookie); public function get($uri, $data); public function post($uri, $data); public function head(); public function body(); public function status(); public function cookie(); public function size();}
curlpp統一的get/post請求是查詢域的發送,統一使用參數數組參數$data發送請求資料集。無資料時用空數組即可。head和cookie也可以通過數組輕鬆設定。
demo:
$uri='http://www.baidu.com';$client = new curlpp();$client->set_head(array('User-Agent' => 'curlpp'));$client->set_cookie(array('key'=>vlaue));$client->set_auto_redirect(true);$client->set_timeout(3000);$data = array();$response = array();if($client->get($uri,$data)){ $response['head'] = $client->head(); $response['cookie'] = $client->cookie(); $response['status'] = $client->status(); $response['content-size'] = $client->size(); $response['content'] = $client->body();}else{ exit('error');}var_dump($response);
下載地址:http://www.wqbuyer.com/demo/