How to scrape a photo from a Twitter Photo URL using PHP
After explaining how to scrape a photo from a Twitter Photo URL using C# (ASP.Net) I decided to port the script PHP so I could use it on WordPress. I ended up using CURL and a regular expression to do the trick.
How to scrape a photo from a Twitter Photo URL with C#
Twitter uses its url shortener to place photo’s in Tweets. I’ve tried processing these URLs in the browser, but cross site scripting measures prevented me from processing the result with jQuery.
I decided to resolve it in C# (as I’m using ASP.Net). The following script leverages a WebClient and a regular expression to extract the photo URL from the shortened URL. This code could be added to a handler or a webservice that can be called from script.