使用hello.js和Cordova进行Twitter身份验证

使用hello.js和Cordova进行Twitter身份验证,cordova,hello.js,Cordova,Hello.js,我修改了hello.js主页()上提供的Cordova示例,使其使用twitter登录,但无法正常工作。基本上,当我尝试twitter hello.js示例中提供的原始代码时,它工作正常,并以通常的权限连接到twitter页面!当我尝试修改代码时,它打开了localhost页面,这非常奇怪 我使用的代码是相当标准的,是对原始代码的简单修改 这是我使用的代码: // Initate the library hello.init({ googl

我修改了hello.js主页()上提供的Cordova示例,使其使用twitter登录,但无法正常工作。基本上,当我尝试twitter hello.js示例中提供的原始代码时,它工作正常,并以通常的权限连接到twitter页面!当我尝试修改代码时,它打开了localhost页面,这非常奇怪

我使用的代码是相当标准的,是对原始代码的简单修改

这是我使用的代码:

        // Initate the library
        hello.init({
            google : ' ... ',
            facebook : ' ... ',
            twitter : 'mkjOc4ESXs5ZVFan5l0hTfSFc',
            windows : ' ... ',
        }, {
            //
            // Define the OAuth2 return URL
            // This can be anything you like, providing its the callback which you have registered with the providers for OAuth2
            // It could even be localhost, e.g. http://localhost/somepath as phonegap is not run from a domain so SameOrigin breaks, instead we take advantage of being able to read the popups URL in PhoneGap
            // redirect_uri : 'http://adodson.com/hello.js/redirect.html'
            redirect_uri : 'http://localhost'
        });
这是按钮

    <button onclick="hello('twitter').login(loginHandler)">Twitter</button>
Twitter

如果您遇到如下登录错误

function loginHandler(resp){
   if(resp.error){
       // Error object type 'invalid_credentials'
   }
}
那么这可能是因为身份验证代理无法识别客户端id。像twitter这样的OAuth1服务需要一个身份验证代理服务,因为它依赖于不能在web客户端公开的秘密

您可以使用HelloJS默认设置为使用的推荐服务,也可以运行自己的服务,有关详细信息,请参阅