0

I'm asking this because previous answers are outdated.

I need to get twitter follower count and ideally without using php and / or API tokens. This code returns an error:

  var twitter_username = 'billgates';
    
    $.ajax({
      url: "https://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names=" + twitter_username,
      dataType: 'jsonp',
      crossDomain: true
    }).done(function(data) {
      console.log(data[0]['followers_count']);
    }).fail(function(data) {
   console.log(data);
  });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>

The error is being return is the following:

   (index):1 Refused to execute script from 'https://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names=billgates&callback=jQuery112406752686864999666_1594556812284&_=1594556812285' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.

although direct url access from browser does return json file.

Can it be fixed or currently no way to get followers count without api?

Runnick
  • 613
  • 2
  • 12
  • 30
  • `dataType: 'jsonp',` — it's JSON, not JSONP – Quentin Jul 12 '20 at 12:44
  • `crossDomain: true` — There's no point in setting this explicitly unless you are making a *same-origin* request that gets **redirected** to be cross-origin. – Quentin Jul 12 '20 at 12:45

0 Answers0