in my code below I don't understand why in the final console.log variable bearer_token is undefined if I've inizializated it within function __call.
home: function () {
var bearer_token;
var cb = new Codebird;
cb.setConsumerKey("Zox*O8n1u", "zaCTe5oI23bxx***CG87e8hkgZgBeIHV7LKp");
cb.__call(
"oauth2_token", {},
function (reply) {
var bearer_token = reply.access_token;
}
);
$.ajax({
url: "http://search.twitter.com/search.json?q=felpone",
dataType: "jsonp",
jsonpCallback: "myFunction",
beforeSend: function (xhr, settings) {
xhr.setRequestHeader('Authorization', 'Bearer ' + bearer_token);
}
});
function myFunction(r) {
console.log(r);
}
console.log(bearer_token);
},