我试图通过此链接从用户登录后获取用户详细信息 - https://api.twitter.com/1.1/account/verify_credentials.json
为了做到这一点,我首先请求oauth_token,第二步我要求 签名,最后我尝试使用oauth_token和签名获取用户数据.在最后一次通话中,我收到了"401未经授权的错误".
我使用过这个cordova插件 - http://ngcordova.com/docs/plugins/oauth/
我想生成APK for android和ios.I我正在使用cordova CLI生成apk.
这是我的代码 -
class TwitterLoginCtrl extends BaseCtrl @register 'TwitterLoginCtrl' @inject '$scope', '$ionicPopup', 'WtaLoading', '$ionicLoading','$cordovaOauth','$http','$cordovaOauthUtility' initialize: -> @$scope.twitterSignIn = @twitterSignIn twitterSignIn: => alert 'Twitter Nisarg' @$cordovaOauth.twitter('[consumer key]','consumer secret').then ((result) => console.log JSON.stringify(result) oauthObject = oauth_consumer_key: '[consumer key]' oauth_nonce: @$cordovaOauthUtility.createNonce(10) oauth_signature_method: 'HMAC-SHA1' oauth_timestamp: Math.round((new Date).getTime() / 1000.0) oauth_version: '1.0' oauth_token: result.oauth_token signatureObj = @$cordovaOauthUtility.createSignature('GET', 'https://api.twitter.com/1.1/account/verify_credentials.json', oauthObject, oauthObject) @$http(url: 'https://api.twitter.com/1.1/account/verify_credentials.json', method: 'GET' , params: angular.extend(oauthObject, oauth_signature: signatureObj.signature), format: "json"). then (data) => **// THIS CALL THROWS 401 UNAUTHORIZED ERROR** console.log JSON.stringify(data) ), (error) -> console.log error
编辑
@$cordovaOauth.twitter('[consumer key]','consumer secret').then ((result) =>
以上电话给我这个结果=>
{ "oauth_token":[access-token], "oauth_token_secret":[access_token_secret], "user_id":"4629415817", "screen_name":"napster", "x_auth_expires":"0" }
每次我得到x_auth_expires.好吗?