salcan
#1
I have a t.co link via referral and I’d like to find the tweet that has that t.co link in it. What’s the best way to go about a search like this with the API?
Thanks
salcan
#2
@happycamper Any thoughts on this? I have access to the paid version of premium api.
@salcan
What’s the use case for finding the Tweet through the API?
Since t.co’s are unique, you can try just using the url: operator for Tweets within the last 30 days:
curl “https://api.twitter.com/1.1/tweets/search/30day/testeroo.json?maxResults=100&query=url:DlTIi21JQv OR url:oVMXJh2y3Q”
However this would waste all of your requests.
1 Like
Hey @happycamper,
I’m trying to do the same thing. My use-case is that I run a web analytics service and when my customers get referral traffic from Twitter I’d like to be able to show them which Tweet the traffic came from.
My service captures the Referer header when visitors land on my customer’s website. When visitors are coming from Twitter, the referrer header contains the shortened t.co link that the user clicked on.
So to be able to show the tweet that brought the traffic to my customer, I’d like to be able to look up a tweet by the t.co link. I tried your method but it doesn’t seem to work for me. Here’s what I tried:
Take the link in this tweet: twitter.com/SamirTalwar/status/1211971755973189632
When you click on the link in the tweet, you land on my website and the referrer is captured as http://t.co/MErQPZ8cGR. When I try to do a full-archive search with the following query “query”:“url:MErQPZ8cGR”, it returns no results. Am I doing something wrong here?
Maybe you can suggest another way for me to link referral traffic to a tweet? If not, how can I get the search to work? I’m happy to pay for the API access to show referring tweets to my customers.