javascript - javascript (2020) 中没有令牌的 Twitter 关注者计数?
问题描述
我问这个是因为以前的答案已经过时了。
我需要获取 twitter 关注者数量,理想情况下不使用 php 和/或 API 令牌。此代码返回错误:
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>
返回的错误如下:
(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.
尽管从浏览器直接访问 url 确实会返回 json 文件。
如果没有 api,它是否可以修复或目前无法获得关注者数量?
解决方案
推荐阅读
- excel - Sumproduct 减去不同月份列中最早月份的总金额
- java - 带有客户端证书返回访问的 https 请求在 android 中被拒绝,但它在 post man 中运行良好,改造和 okhttp3 返回相同的错误
- java - 从另一个子 JFrame 向 JFrame 发送数据而不打开新的 JFrame
- python - 即使在部署之后,heroku 应用程序也没有运行
- svg - 如何在 jasper 报告中使用透明 SVG 并导出为 pdf
- php - NumberFormatter::PERCENT 带小数
- linux - 查找一个目录中缺少的文件在一秒钟内 - 需要忽略文件扩展名
- angular - net:ERR_FAILED - 我的应用程序(Ionic 4 / Angular 7)在尝试导出 Highcharts 时出错
- ios - 用 WKWebView 替换 UIWebView - 字体不适用
- c# - 在显示属性中使用 appsettings 键