admin管理员组文章数量:1293746
I want to get an access_token according to this documentation . I use javascript.
$.ajax({
url: "",
type: "POST",
contentType: "json",
data: {
oauth_consumer_key: "DFwQqCnOTaYVbZQdBFqpR",
oauth_signature_method: "HMAC-SHA1",
oauth_timestamp: parseInt((new Date()).getTime() / 1000),
oauth_nonce: "R" + parseInt((new Date()).getTime() / 1000),
oauth_version: "1.0"
},
success: function (data) {
debugger;
},
error: function (a, b, c) {
debugger;
}
});
But it does not work at all. Always return error, never success.
I want to get an access_token according to this documentation http://dev.twitter./doc/post/oauth/request_token. I use javascript.
$.ajax({
url: "http://api.twitter./oauth/request_token",
type: "POST",
contentType: "json",
data: {
oauth_consumer_key: "DFwQqCnOTaYVbZQdBFqpR",
oauth_signature_method: "HMAC-SHA1",
oauth_timestamp: parseInt((new Date()).getTime() / 1000),
oauth_nonce: "R" + parseInt((new Date()).getTime() / 1000),
oauth_version: "1.0"
},
success: function (data) {
debugger;
},
error: function (a, b, c) {
debugger;
}
});
But it does not work at all. Always return error, never success.
Share edited Jun 16, 2011 at 17:42 Alexander asked Jun 16, 2011 at 17:36 AlexanderAlexander 6073 gold badges11 silver badges23 bronze badges 4- Please indent your code with four spaces instead of adding HTML tags. – SLaks Commented Jun 16, 2011 at 17:38
- Hi Alexander. You can use 4 spaces (or the {} button in the question entry form) to format your code to be more readable, as I have done so above. Also, html br elements are not necessary (and are in fact ignored) – Matt Commented Jun 16, 2011 at 17:39
- Also, please define "does not work" - what behavior, exactly, are you seeing? – Matt Commented Jun 16, 2011 at 17:41
- Maybe a stupid suggestion, but just to be sure; Are you sure you have included jQuery in your HTML as well? – fijter Commented Jun 16, 2011 at 17:49
3 Answers
Reset to default 3Check user login & signup provided by Twitter's @Anywhere JavaScript library. https://dev.twitter./docs/anywhere/wele#login-signup
That may be exactly what you want, much easier to use than the raw OAuth.
You are not signing your request. You can read a more in depth direction on how to sign an OAuth reqeust on dev.twitter.. You will likely want to use a JavaScript library to generate oauth_signature.
You're probably calling this script outside the api.twitter.
domain. Try with dataType: "jsonp"
.
本文标签: Twitter authentication with JavascriptStack Overflow
版权声明:本文标题:Twitter authentication with Javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741586519a2386877.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论