0

I've registered my application at Twitter as depicted below

enter image description here

I'm trying to fetch a JSON file of tweets with a specific hashtag like "#dog". However, I'm having authentication problems. I'm using Javascript.

http://jsfiddle.net/rgapegw3/

 /*
 consumer_key=I_HAVE
 &consumer_secret=I_HAVE
 &user_token=I_HAVE-I_HAVE
 &user_secret=I_HAVE 
*/

$.getJSON("https://api.twitter.com/1.1/search/tweets.json?q=%23colombia&result_type=recent",

function (data) {
    alert("IT WORKED!");
},function(data){
    console.log("problem")
});
yavg
  • 2,761
  • 7
  • 45
  • 115
  • classic, you redacted everything BUT the secret – Lawrence Cherone Jun 12 '17 at 22:03
  • https://stackoverflow.com/questions/17143985/twitter-api-error-215 – Lawrence Cherone Jun 12 '17 at 22:08
  • @LawrenceCherone what do you say? – yavg Jun 12 '17 at 22:28
  • 1
    you cant use version 1.1 of the api as it requires oauth authentication, you will need to proxy the call through server side code which can handle the oauth.. – Lawrence Cherone Jun 12 '17 at 22:31
  • @LawrenceCherone I'll look at the tutorial you passed me. thank you very much. But I believed that everything could be done in a simple web request. – yavg Jun 12 '17 at 22:58
  • np, for the most part it can, check out https://stackoverflow.com/questions/17084201/jquery-tweet-js-plugin-is-not-working-how-to-show-tweets/17084479#17084479 for a simple proxy, which can be adapted for your needs – Lawrence Cherone Jun 12 '17 at 23:05
  • @LawrenceCherone I get confused a bit. I need to do the web service specifically from angular.js or jquery. But I'm not using php or backend. Only from front-end – yavg Jun 13 '17 at 15:11
  • do some research its not possible or advised with just javascript, unless you implement the complete oauth process (see the php code), you would also need to pass your twitter app private keys to the client, not good.. its the standard with oauth apis is to have a backend. – Lawrence Cherone Jun 14 '17 at 15:04
  • @LawrenceCherone In conclusion if or if, I should use php in my case. – yavg Jun 14 '17 at 15:07
  • For a simple proxy, you could use the one in the link, or if you want something more advanced/official use there libs https://dev.twitter.com/resources/twitter-libraries – Lawrence Cherone Jun 14 '17 at 15:09
  • This is a good one: https://twitteroauth.com/ – Lawrence Cherone Jun 14 '17 at 15:11

0 Answers0