开发者

Twitting URLs with # in them and getting their count

The goal here is to be able to "tweet" a link of the format www.example.com/page.aspx#1, and get the number of "tweets" for that link... Basically, what the out-of-the-box Twitter button does for any normal开发者_开发问答 link.

Reason for this is because the page displays different content based on the ID after the #, so there is a need to count which specific item was "tweeted" and how many times.

I tried passing that URL to the Twitter service to get the count (http://urls.api.twitter.com/1/urls/count.json?url=), but the JSON object I get back only has {"count":0,"url":"www.example.com/page.aspx/"}.

The link for the Twitter button looks like this (done in JavaScript)

var twtLink = 'http://twitter.com/intent/tweet?url='+encodeURIComponent(twtUrl)+'&counturl='+encodeURIComponent(twtUrl);

Any suggestions would be appreciated.

Thanks!


Twitter actually re-interrupts all URL's with their own custom t.co wrapper. This is good news for your use case. You can use these unique t.co links with the counter API.

If you include the attribute &include_entities=1 to the end of some Twitter REST API calls you get back expanded info including the URL's in the tweets. You will see the original URL as well as the shortened URL version. Pass the shortened URL version into the counter API.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜