pear / http_oauth
OAuth 1.0a 协议的实现。
0.3.2
2016-01-08 15:46 UTC
Requires
- php: >=5.1.2
- ext-date: *
- ext-hash: *
- ext-spl: *
- pear/http_request2: ^2.0.0
- pear/pear-core-minimal: ^1.9.0
Suggests
- pear/cache_lite: Caching of requests.
- pear/log: Allows logging requests for debugging
This package is auto-updated.
Last update: 2024-09-07 18:22:50 UTC
README
HTTP_OAuth 是一个实现 OAuth 1.0a 协议的 PEAR 包。提供了消费者、提供者(请求和响应)类。以下是一些消费者示例
HTTP_OAuth_Consumer
主要的消费者类,帮助消费者建立 OAuth 凭证并发出 OAuth 请求。
示例
$consumer = new HTTP_OAuth_Consumer('key', 'secret'); $consumer->getRequestToken('http://example.com/oauth/request_token', $callback); // Store tokens $_SESSION['token'] = $consumer->getToken(); $_SESSION['token_secret'] = $consumer->getTokenSecret(); $url = $consumer->getAuthorizeUrl('http://example.com/oauth/authorize'); http_redirect($url); // function from pecl_http // When they come back via the $callback url $consumer = new HTTP_OAuth_Consumer('key', 'secret', $_SESSION['token'], $_SESSION['token_secret']); $consumer->getAccessToken('http://example.com/oauth/access_token'); // Store tokens $_SESSION['token'] = $consumer->getToken(); $_SESSION['token_secret'] = $consumer->getTokenSecret(); // $response is an instance of HTTP_OAuth_Consumer_Response $response = $consumer->sendRequest('http://example.com/oauth/protected_resource');