I’m currently working on a research project that needs to collect checkin tweets from Twitter.
A crawler has been implemented and tweets I got are in the format like: “I’m at SOMEWHERE 4sq.com/xW1q**”
When click on the link “4sq.com/xW1q**”, the page will be redirect to URL like “foursquare.com/SOMEONE/checkin/CHECKINID&SIGNATURE“. I need to extract the CHECKINID and SIGNATURE in order to get detailed checkin infomation.
What I want to ask is that how can I program to expand the shorter URL to the longer URL in order to obtain the checkin ID and a signature ? Someone suggest that I should make a HEAD request to get the the full URL, but I don’t know how to it.
Thanks in advance.
New more correct answer
4sq.com uses bit.ly to shorten URLs, so you should use the bit.ly API to expand the URL: http://code.google.com/p/bitly-api/wiki/ApiDocumentation
AHEADrequest is the right thing to do.To do a
HEADrequest in curl:Which returns the headers like so:
If you tell us more about what language you’re coding in we can give you more specific advice about how to make a HEAD request and get that header value.