【问题标题】:Ionic Framework Twitter integration离子框架 Twitter 集成
【发布时间】:2016-12-25 14:43:05
【问题描述】:

我目前正在开展一个项目,我必须在其中使用 Ionic 框架进行 twitter 集成。

我使用的是来自 ionic 论坛的示例程序:http://forum.ionicframework.com/t/twitter-integration-with-jsoauth/3936

可在 bitbucket:https://bitbucket.org/aaronksaunders/ionic.twitter.sample

我已经以两种方式进行了测试,即使用 ionic serve 和在模拟器上,但结果相同:每当我点击登录时,都会出现一个带有地址的新浏览器窗口:https://api.twitter.com/oauth/authorize?出现包含以下错误消息。

Whoa there!
There is no request token for this page. That's the special key we need
from applications asking to use your Twitter account. Please go back to
the site or application that sent you here and try again; it was probably 
just a mistake.

我已将我的 twitter API Key 和 API Secret 放在适当的位置。

【问题讨论】:

  • 我也遇到了同样的问题
  • 已经快一个月了,我仍然没有解决这个问题......@Drastick如果你找到任何合适的解决方案,请告诉我......

标签: angularjs twitter ionic-framework oauth


【解决方案1】:

我其实很喜欢使用hello.js

这是一个很棒的库,可以为您处理社交媒体令牌。

初始化示例:

hello.init({
    facebook : '12345678912345'
}, {
    // Define the OAuth2 return URL
    redirect_uri : 'http://adodson.com/hello.js/redirect.html'
});

登录:

hello( "facebook" ).login().then( function(){
    alert("You are signed in to Facebook");
}, function( e ){
    alert("Signin error: " + e.error.message );
});

登录后,您可以拨打任何电话到您选择的社交媒体帐户。

【讨论】:

    【解决方案2】:

    您应该尽可能使用ngCordova

    Oauth plugin 文档说明您需要使用 jsSHA 来通过 Twitter 进行身份验证。

    要在您的项目中使用 Twitter,您的项目中必须包含开源库 jsSHA。这是因为 Twitter 需要使用 HMAC-SHA1 对请求进行签名,而 JavaScript 本身没有。

    更多信息请参见 ngCordova Oauth 插件文档。

    【讨论】:

    • 是的,我已经读过这个文档很多次了。我还将 jsSHA 包含到我的项目中。但无济于事。请给出一些示例代码来解决它。
    【解决方案3】:

    按照@darryn.ten 的建议,尝试将 Cordova oAuth 插件与应用内浏览器插件结合使用。以下是如何使用 oAuth 插件触发 Twitter 登录的示例:

    控制器

     angular.module('myApp')
           .controller('MyAppCtrl', ['$scope', '$cordovaOauth', function($scope, $cordovaOauth) {
    
           $scope.twitterLogin = function() {
                $cordovaOauth.twitter(<consumer key>, <secret key>).then(function(r) {
                    //retrieve oAuth token from result
                }, function(error) {
                    //show error
                });
            }
        }])
    

    查看

    <a class="button button-calm" href="#" ng-click="twitterLogin()">Twitter Login</a>
    

    请参阅文档here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-25
      • 2016-11-12
      • 2015-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多