显示未经身份验证的 LinkedIn 分享数 client-only
Display number of LinkedIn shares, client-only, without authentication
https://www.linkedin.com/countserv/count/share?url=whosebug.com&format=json 正确显示了 meteor.com
的股票数量(目前为 935)。
我正在尝试在客户端中显示该号码:
$.getJSON('https://www.linkedin.com/countserv/count/share?url=whosebug.com&format=json&callback=?', { dataType: "jsonp" }, function (data) {
alert(data.count);
});
由于返回 X-Content-Type-Options: nosniff
header,我在 Chrome:
中收到 refuse to execute script 错误
Refused to execute script from 'https://www.linkedin.com/countserv/count/share?url=http://whosebug.com&format=json&callback=jQuery210014496755180880427_1426891580561&_=1426891580562' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
是否有解决此问题的方法(除了通过代理路由请求),还是根本不可能,as is the case with GitHub, unless LinkedIn fixes the issue?
这看起来像是这个 post 的副本:Get LinkedIn share count JSONP
这是那边推荐的答案:
myCallback = function(data) {
alert(data.count);
};
var url = "https://www.linkedin.com/countserv/count/share?url=http://whosebug.com&format=jsonp&callback=myCallback";
$.getScript(url);
这里有一个Fiddle来演示:https://jsfiddle.net/z9u20ucm/1/
https://www.linkedin.com/countserv/count/share?url=whosebug.com&format=json 正确显示了 meteor.com
的股票数量(目前为 935)。
我正在尝试在客户端中显示该号码:
$.getJSON('https://www.linkedin.com/countserv/count/share?url=whosebug.com&format=json&callback=?', { dataType: "jsonp" }, function (data) {
alert(data.count);
});
由于返回 X-Content-Type-Options: nosniff
header,我在 Chrome:
Refused to execute script from 'https://www.linkedin.com/countserv/count/share?url=http://whosebug.com&format=json&callback=jQuery210014496755180880427_1426891580561&_=1426891580562' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
是否有解决此问题的方法(除了通过代理路由请求),还是根本不可能,as is the case with GitHub, unless LinkedIn fixes the issue?
这看起来像是这个 post 的副本:Get LinkedIn share count JSONP
这是那边推荐的答案:
myCallback = function(data) {
alert(data.count);
};
var url = "https://www.linkedin.com/countserv/count/share?url=http://whosebug.com&format=jsonp&callback=myCallback";
$.getScript(url);
这里有一个Fiddle来演示:https://jsfiddle.net/z9u20ucm/1/