gpt4 book ai didi

javascript - Twitter codebird.js 无需 pincode 授权

转载 作者:行者123 更新时间:2023-11-28 07:58:59 27 4
gpt4 key购买 nike

我想问是否可以通过绕过 pincode 输入使用 codebird.js 在 Twitter 上授权应用程序。这是我的代码(使用 pincode):

$(document).ready(function () {
$("#twitterLogin").on("click", function() {
// handle button click here
cb.__call(
"oauth_requestToken",
{oauth_callback: "oob"},
function (reply) {
// stores it
cb.setToken(reply.oauth_token, reply.oauth_token_secret);

// gets the authorize screen URL
cb.__call(
"oauth_authorize",
{},
function (auth_url) {
//window.open(auth_url);
window.open(auth_url,"MsgWindow",'height=202,width=800');
}
);
}
);

});

$("#tweet").on("click", function() {
cb.__call(
"oauth_accessToken",
{oauth_verifier: document.getElementById("rhymeText").value},
function (reply) {
// store the authenticated token, which may be different from the request
token (!)
cb.setToken(access_token_key, access_token_secret);
alert('Auth completed!');
// if you need to persist the login after page reload,
// consider storing the token in a cookie or HTML5 local storage
}
);
});

$("#auth").on("click", function() {
cb.__call(
"statuses_updateWithMedia",
{
"status": "The bird is on fire!. @gaspersopi",
"media[]": "iVB..SuQmCC"
},
function (reply) {
console.log(reply);
alert('Image posted!');
}
);

});

var consumer_key = "ao856hSerLRDH1xXyfSXvvYRs";
var consumer_secret = "9jMK2f74QyCeAlpikmn4VIfjZkvnOxQ3pmYEviez86yaS9PRoH";

var access_token_key = "955855880-ko408mWNBWbWLbDqe2MjF3cpXvmPKzVQzFZW5YOj";
var access_token_secret = "J6Yh0ZvAoWaeve7CMCQ9RbRLcj8ISbNTZ4qVKCBp95N1U";

var cb = new Codebird;
var current_url = location.toString();

cb.setConsumerKey(consumer_key, consumer_secret);

});

这也是我所输入的,但它不起作用,因为 match 方法总是返回 null。

var cb          = new Codebird;
var current_url = location.toString();
var query = current_url.match(/\?(.+)$/).split("&");
var parameters = {};
var parameter;

cb.setConsumerKey("STUFF", "HERE");

for (var i = 0; i < query.length; i++) {
parameter = query[i].split("=");
if (parameter.length === 1) {
parameter[1] = "";
}
parameters[decodeURIComponent(parameter[0])] = decodeURIComponent(parameter[1]);
}

// check if oauth_verifier is set
if (typeof parameters.oauth_verifier !== "undefined") {
// assign stored request token parameters to codebird here
// ...
cb.setToken(stored_somewhere.oauth_token, stored_somewhere.oauth_token_secret);

cb.__call(
"oauth_accessToken",
{
oauth_verifier: parameters.oauth_verifier
},
function (reply) {
cb.setToken(reply.oauth_token, reply.oauth_token_secret);

// if you need to persist the login after page reload,
// consider storing the token in a cookie or HTML5 local storage
}
);
}

提前致谢..

最佳答案

cb.__call(
"oauth_authorize",
**{oauth_callback: "yourdomain/callback.html"}**,
function (auth_url) {
//window.open(auth_url);
window.open(auth_url,"MsgWindow",'height=202,width=800');
}
);

您应该放置 oauth_callback 参数,它已注册到您的应用程序。
和回调 url 页面使 codind 得到回复。

关于javascript - Twitter codebird.js 无需 pincode 授权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25670001/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com