• 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
https://www.neowin.net/forum/topic/1197255-help-with-javascript/
Share on other sites

7 answers to this question

Recommended Posts

  • 0
  On 19/01/2014 at 17:01, spacer said:

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
}
]
}
  • 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.

  • 0
  On 19/01/2014 at 18:07, Lingwo said:

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 :/

  • 0

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

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

    • No registered users viewing this page.
  • Posts

    • Chinese? It sounds extremely dangerous. I’ll reconsider buying a Meta Quest 3.
    • - What's your salary? Is it more than $100k a year? - Nah, it's $100 mil a year.
    • Compared to my ear buds which are the size of a matchbox, cover a much broader frequency range, and work everywhere without setup? Yeah, still not buying this as a replacement.
    • Meta's Superintelligence team staffed by 50% Chinese talent, 40% ex-OpenAI by Hamid Ganji Mark Zuckerberg's latest big bet at Meta involves building a team of the best AI superstars in the market to lead the so-called Superintelligence Labs. The goal of this team is to develop AI models that will ultimately lead to Artificial General Intelligence (AGI). AGI refers to an AI model with capabilities comparable to, or even beyond, those of the human brain. Achieving human-level cognitive abilities with an AI model requires substantial investments, as well as hiring the best talent to build such a system. That's why Meta is throwing hundreds of millions of dollars at AI researchers from OpenAI, Apple, and other companies to recruit them for its Superintelligence team. A user on X has now shared a spreadsheet that provides us with some unique insights into Meta's Superintelligence team and the origins of its 44 employees. The leaker claims this information comes from an anonymous Meta employee. The listing claims that 50 percent of the staff at the Superintelligence team are from China, which demonstrates the significant role of Chinese or Chinese-origin researchers in Met's AI efforts. Additionally, 75 percent of these staff hold PhDs, and 70 percent of them work as researchers. Interestingly, 40 percent of the staff are ex-OpenAI employees whom Mark Zuckerberg poached from the maker of ChatGPT. Additionally, 20 percent of Meta's Superintelligence team members come from Google DeepMind, and another 15 percent come from Scale AI, a startup that Meta recently acquired in a $15 billion deal. Another interesting point is that 75 percent of the Superintelligence team are first-generation immigrants. The leaker claims that each of these employees is now earning between $10 million and $100 million per year, although Meta still needs to confirm these substantial figures. However, it has already been reported that Meta is offering up to $100 million in signup bonuses to poach the best AI talent from OpenAI and other rivals. The revelation that half of Meta's Superintelligence team consists of Chinese nationals could trigger concerns within the Trump administration and Congress.
    • From a quick Google it seems 6GHz is optional on 802.11be. Ubiquiti has one, Unifi U7 Lite.
  • Recent Achievements

    • First Post
      nobody9 earned a badge
      First Post
    • One Month Later
      Ricky Chan earned a badge
      One Month Later
    • First Post
      leoniDAM earned a badge
      First Post
    • Reacting Well
      Ian_ earned a badge
      Reacting Well
    • One Month Later
      Ian_ earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      505
    2. 2
      ATLien_0
      207
    3. 3
      Michael Scrip
      206
    4. 4
      Xenon
      138
    5. 5
      +FloatingFatMan
      112
  • Tell a friend

    Love Neowin? Tell a friend!