3

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 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.
4

3 回答 3

2

您必须放置某种 get 参数

page.php?referer=twitter

并检查它

<?php
if ($_GET['referer'] == "twitter")
{
    //do stuff
}
于 2011-07-10T13:47:49.203 回答
1

我认为最可靠的方法是使用您自己的某种标识符共享每个链接。

例如,

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

您可以轻松地在 PHP 或您想要的任何其他语言中实现对 ref 参数的跟踪。

于 2011-07-10T13:45:16.440 回答
0

t.co 不携带原始推荐人通过。因此,您无法在重定向后捕获此内容。您只会看到一个 t.co/foobar 引荐来源网址。

于 2011-07-31T05:50:40.857 回答