标签:
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(); }
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/
标签:
原文地址:http://my.oschina.net/wqbuyer/blog/359833