sshilko / digitsoauth
Fabric.io (Digits) 账户验证 (OAuth)
0.0.5
2015-12-15 20:38 UTC
Requires
- php: >=5.3.0
- zendframework/zendframework1: ^1.12
README
通过 Fabric.io / Digits (Twitter) 验证通过电话号码认证的用户。最初目的是在服务器端验证从移动客户端获得的 Fabric 令牌。
客户端必须发送 clientToken & clientTokenSecret 以供后端验证。
后端需要知道用于对 api.digits.com 的 OAuth 请求进行 HMAC 签名的 Consumer Key & Secret。
使用 ZendFramework 1 的 Zend Oauth Client 部分。
要求
- 用于 Zend_Oauth_Client 的 ZendFramework 1 库
- PHP 5.3.0 命名空间
- 用于 CONSUMER KEY (API KEY) 和 CONSUMER SECRET (API SECRET) 的 Fabric 账户
基本用法(服务器端令牌验证)
$account = new \Digitsoauth\Account($accessToken,
$accessTokenSecret,
$consumerKey,
$consumerSecret);
#calls https://api.digits.com/1.1/sdk/account.json to verify $accessToken
#returns user data (success)
#or Zend_Http_Response (error)
$result = $account->verifyCredentials();
if ($result instanceof \Zend_Http_Response) {
#process errors (network, credentials, ...)
echo (string) $result;
} else {
#got the response array with digits identifier & phone number
$digitsId = $result['id_str'];
$digitsPhone = $result['phone_number'];
}
参考
- https://docs.fabric.io/ios/digits/oauth-echo.html
- fabric.io
- dev.twitter.com
- https://dev.twitter.com/oauth/overview/creating-signatures
- https://docs.fabric.io/web/digits/getting-started.html#set-up-digits-authentication
- http://nouncer.com/oauth/signature.html
- http://framework.zend.com/manual/1.12/en/zend.oauth.introduction.html