1

我试着统计社交网络的数量,在我的例子中是 twitter、linkedin 和 gplus。我用 jquery 调用了社交网络 api,但在我的浏览器控制台中对所有三个社交网络都出现了错误(从浏览器访问相同的 url 工作正常)

XMLHttpRequest 无法加载https://cdn.api.twitter.com/1/urls/count.json?url=http://maki.host.com:3000/blog/posts/fdsfdsfds。Access-Control-Allow-Origin 不允许来源http://maki.host.com:3000 。

(推特)

我尝试修改我的标题以允许我的主机没有任何变化,也许有人有同样的问题并且可以帮助我。谢谢

4

1 回答 1

0

You should probably be using the APIs for each respective Social Media site as opposed to using AJAX to directly try and scrape or make API calls. As an example, the following will retrieve an Activity on the Google+ network that you can use to retrieve engagement counts:

https://developers.google.com/apis-explorer/#p/plus/v1/plus.activities.get?activityId=z120dncann32i3gu222uydqhrp34gx5np&fields=object(plusoners%252Creplies%252Cresharers)&_h=3&

For Google+ you should be using the official Google+ API client, demonstrated on the Google+ JavaScript Quickstart.

As another example, if you are trying to get a count of people who have mentioned a user on Twitter, explore the API for Twitter to find the query you are looking for.

You would then use one of the various JavaScript libraries for Twitter to manage API calls.

For Facebook, you should be using the Facebook JavaScript library.

于 2013-10-18T21:17:11.120 回答