1
我想問一下是否有可能通過繞過pincode條目授權應用程序在twitter上使用codebird.js。這是我的代碼(使用PIN碼):Twitter codebird.js授權沒有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);
});
這就是我也tyied,但它沒有工作,因爲匹配方法始終返回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
}
);
}
在此先感謝..
tnx,它解決了... – user3712755 2014-12-01 16:13:36