开发者

Any way to capture the referring t.co link from Twitter?

I want to post multiple versions of the same link on Twitter but I want to capture them with unique identifiers when they hit my server.

Twitter partially devised a mechanism for this, for example if I post www.example.com开发者_C百科 into a twitter message, Twitter will automatically resolve it into a custom URL beginning with t.covia a 301 re-direct.

more information: Twitter Link Wrapping

I want to capture this re-directed URL so I can have a unique identifier for similar links on Twitter.

Is there a way to do it? Or is there a better way to handle this problem?

(I'm looking for a solution in PHP/JS or if need be any possible way with any language)

EDIT: The link needs to be exactly the same in Twitter, can't have query parameters or hash on the link.

EDIT2: More investigation, the t.co link will remain the same if it's the same link url attributed to the same profile. For example, two links of www.example.com on the same twitter profile will yield the same t.co link, but the t.co link will be different if it's attributed to another profile. I guess this to mean even if there is a workaround for the above issue, there is still no way to differentiate exactly the same links on the same twitter profile server side.

EDIT3 12/26/11 whats interesting too is that t.co differentiates between http:// and https so you can in theory 'display' two of the same links on the same profile and they will look physically the same in Twitter but the t.co redirect link will be different. It will link to the http and https versions.

  • Ultimately, what I'm trying to do is find out the tweet i.d of of a referring link that hits my server without resorting to URL params.


You'll have to place some kind of get parameter

page.php?referer=twitter

and check it like

<?php
if ($_GET['referer'] == "twitter")
{
    //do stuff
}


I think the most reliable way to do this would be to share each link with some sort of an identifier of your own.

For example,

  • www.domain.com/page-1?ref=1
  • www.domain.com/page-1?ref=2
  • etc.

You could easily implement tracking for the ref parameter in PHP or any other language you want.


t.co doesn't carry the original referrer through. So you can't capture this after the redirection. You'll only see a t.co/foobar referrer.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜