jamm / http
通过HTTP请求和响应轻松操作对象
1.0.0
2014-04-16 12:55 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-14 14:41:33 UTC
README
通过HTTP请求和响应轻松操作对象
发送请求的示例
$Response = new Response();
$Request = new Request();
$Request->setMethod(Request::method_POST);
$Request->setHeader('Authorization', 'auth_token');
$Request->setDataKey('some_post_key', 'some value');
$Request->Send('https://api.example.com', $Response);
print $Response->getBody();
##功能 请求和响应中的头部不区分大小写:
$Request->setHeader('Authorization', 'token');
$Request->setHeader('authorization', 'auth_token');
// second line will not create new header and will update existing one
// $Request->getHeaders('AUTHORIZATION') will return:
// auth_token
响应体可以从JSON或XML自动解包
// next line will create header Accept: JSON in request,
// and body of response will be automatically decoded from JSON
$Response->setSerializer(new SerializerJSON());
SSL支持
易于测试和扩展
##许可证 MIT