• 0

Help with Javascript


Question

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

7 answers to this question

Recommended Posts

  • 0

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

  • 0

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

  • 0

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

  • 0

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

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.