Mysterioux Posted January 19, 2014 Share Posted January 19, 2014 I'm not that good with Javascript and would appreciate it alot if anyone of you could help me with a little problem. <if test="$this->settings['showTwitter']=='yes'"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript"> $(function(){ $.ajax({ url: 'http://api.twitter.com/1/users/show.json', data: {screen_name: 'kwcommunity'}, dataType: 'jsonp', success: function(data) { $('#followers').html(data.followers_count); } }); }); </script> <a href="{$this->settings['twitterURL']}" title="Follow us on Twitter" class='twitterButton' target='_blank'>Twitter: <span id="followers"></span></a> </if> It stopped working, just like that. http://awesomescreenshot.com/022285bn35 Link to comment Share on other sites More sharing options...
0 spacer Posted January 19, 2014 Share Posted January 19, 2014 As of jQuery 1.4, ajax calls will fail silently if the JSON return is improperly formatted. Have you verified that what's coming back from the server is valid? You can go here for a JSON parser, if you need one. Link to comment Share on other sites More sharing options...
0 Mysterioux Posted January 19, 2014 Author Share Posted January 19, 2014 As of jQuery 1.4, ajax calls will fail silently if the JSON return is improperly formatted. Have you verified that what's coming back from the server is valid? You can go here for a JSON parser, if you need one. I didnt code this, i stink at this stuff. No idea if its formatted properly or not. And what i'm getting from the JSON Parser is. { "errors":[ { "message":"The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.", "code":68 } ] } Link to comment Share on other sites More sharing options...
0 spacer Posted January 19, 2014 Share Posted January 19, 2014 If that's the return value that you're getting from the server, then it looks like the API your script was using is no longer available on the server. The return data is formatted correctly, but it doesn't have a "followers_count" property that your script is expecting. The script isn't coded to handle errors, and it doesn't look like it displays anything in the event that it doesn't have a "followers_count". (at least the portion of code that you quoted) If you don't have access to the server code, then you need to contact your provider or whichever party does. They may have just updated/changed their API and still offer similar services, but in a different manner. edit: just noticed the API you're using is from Twitter, so you likely don't have access to change the code yourself. Bummer. Twitter does document their APIs though, so just check the documentation to see how to use their new version of their services. Link to comment Share on other sites More sharing options...
0 Lingwo Posted January 19, 2014 Share Posted January 19, 2014 You could try in the URL: http://api.twitter.com/1.1/users/show.json If that doesn't work, i'd try and search the Twitter API documentation for an alternative API call. Link to comment Share on other sites More sharing options...
0 Mysterioux Posted January 19, 2014 Author Share Posted January 19, 2014 You could try in the URL: http://api.twitter.com/1.1/users/show.json If that doesn't work, i'd try and search the Twitter API documentation for an alternative API call. I did that.. but it doesnt work, i've tried searching the API documentation but i cant find anything :/ Link to comment Share on other sites More sharing options...
0 Lingwo Posted January 19, 2014 Share Posted January 19, 2014 Just had a quick look. For what you need to do, i believe you'll need to authenticate yourself with Twitter which will require a bit more work. I'd look at the documentation and see if you can do it yourself. Link to comment Share on other sites More sharing options...
0 mollick2 Posted January 25, 2014 Share Posted January 25, 2014 Twitter decommissioned the v1.0 API last August. The 1.1 requires you to register your application with twitter in order to use the API. Visit this link to find out how to setup an app: https://dev.twitter.com/docs/auth/using-oauth You'll want to use this function for getting the followers: https://dev.twitter.com/docs/api/1.1/get/followers/ids Link to comment Share on other sites More sharing options...
Question
Mysterioux
I'm not that good with Javascript and would appreciate it alot if anyone of you could help me with a little problem.
It stopped working, just like that.
http://awesomescreenshot.com/022285bn35
Link to comment
Share on other sites
7 answers to this question
Recommended Posts