Skip to content

Instantly share code, notes, and snippets.

@baptx baptx/twitter_api_1.1.js
Last active Oct 27, 2018

Embed
What would you like to do?
Access Twitter API 1.1 in browser
/* Access Twitter API 1.1 in browser.
** Get your access keys to use Twitter API 1.1: https://dev.twitter.com/docs/auth/tokens-devtwittercom
** Format JSON in Firefox: https://addons.mozilla.org/EN-us/firefox/addon/jsonview/
** You can change Twitter API URL and Twitter screen_name, then execute script from a trusted web page without CSP protection like about:blank in Firefox Scratchpad or any other browser console.
*/
var script = document.createElement("script");
script.setAttribute("src", "https://pastebin.com/raw/HFjqYLdG"); // http://oauth.googlecode.com/svn/code/javascript/oauth.js (down)
document.body.appendChild(script);
script.addEventListener("load", function() {
var script2 = document.createElement("script");
script2.setAttribute("src", "https://pastebin.com/raw/M0N8JKwf"); // http://pajhome.org.uk/crypt/md5/sha1.js
document.head.appendChild(script2);
script2.addEventListener("load", function() {
var url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
var accessor = {
token: "XXX",
tokenSecret: "XXX",
consumerKey : "XXX",
consumerSecret: "XXX"
};
var message = {
action: url,
method: "GET",
parameters: {screen_name: "baptx"}
};
OAuth.completeRequest(message, accessor);
OAuth.SignatureMethod.sign(message, accessor);
document.location = url + '?' + OAuth.formEncode(message.parameters);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.