baptx

twitter_api_1.1

Mar 5th, 2013 (edited)
1,070
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Access Twitter API 1.1 in browser.
  2. ** Get your access keys to use Twitter API 1.1: https://dev.twitter.com/docs/auth/tokens-devtwittercom
  3. ** Format JSON in Firefox: https://addons.mozilla.org/EN-us/firefox/addon/jsonview/
  4. ** 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.
  5. */
  6.  
  7.  
  8. var script = document.createElement("script");
  9. script.setAttribute("src", "https://pastebin.com/raw/HFjqYLdG"); // http://oauth.googlecode.com/svn/code/javascript/oauth.js (down)
  10. document.body.appendChild(script);
  11. script.addEventListener("load", function() {
  12.     var script2 = document.createElement("script");
  13.     script2.setAttribute("src", "https://pastebin.com/raw/M0N8JKwf"); // http://pajhome.org.uk/crypt/md5/sha1.js
  14.     document.head.appendChild(script2);
  15.     script2.addEventListener("load", function() {
  16.         var url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
  17.         var accessor = {
  18.             token: "YYY",
  19.             tokenSecret: "YYY",
  20.             consumerKey : "YYY",
  21.             consumerSecret: "YYY"
  22.         };
  23.         var message = {
  24.             action: url,
  25.             method: "GET",
  26.             parameters: {screen_name: "jack"}
  27.         };
  28.         OAuth.completeRequest(message, accessor);
  29.         OAuth.SignatureMethod.sign(message, accessor);
  30.         document.location = url + '?' + OAuth.formEncode(message.parameters);
  31.     });
  32. });
Add Comment
Please, Sign In to add comment