您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息
三六零分类信息网 > 郴州分类信息网,免费分类信息发布

PHP HTTP 客户端和框架:Guzzle

2024/3/21 10:44:19发布58次查看
guzzle是一个php http 客户端和框架,用于构建 restful web service 客户端。all the power of curl with a simple interface.持久连接和并行请求streams request and response bodiesservice descriptions for quickly building clients.powered by the symfony2 eventdispatcher.use all of the code or only specific components.plugins for caching, logging, oauth, mocks, and moreincludes a custom node.js webserver to test your clients.
get('/user')->setauth('user', 'pass');// send the request and get the response$response = $request->send();echo $response->getbody();// >>> {type:user, ...echo $response->getheader('content-length');// >>> 792// create a client to work with the twitter api$client = new client('https://api.twitter.com/{version}', array( 'version' => '1.1'));// sign all requests with the oauthplugin$client->addsubscriber(new guzzle\plugin\oauth\oauthplugin(array( 'consumer_key' => '***', 'consumer_secret' => '***', 'token' => '***', 'token_secret' => '***')));echo $client->get('statuses/user_timeline.json')->send()->getbody();// >>> {public_gists:6,type:user ...// create a tweet using post$request = $client->post('statuses/update.json', null, array( 'status' => 'tweeted with guzzle, http://guzzlephp.org'));// send the request and parse the json response into an array$data = $request->send()->json();echo $data['text'];// >>> tweeted with guzzle, http://t.co/kngjmfrk
复制代码
项目主页:http://www.open-open.com/lib/view/home/1392714245460
郴州分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录