getting the correct image url
php
Solution
<?php
function get_url($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
if (!curl_errno($ch)) {
$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
}
curl_close($ch);
return $url;
}
echo get_url("http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&ASIN=B008EYEYBA&Format=_SL110_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=mytwitterpage-20");
Source
Problem
i have this image link below: ``` http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&ASIN=B008EYEYBA&Format=_SL110_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=mytwitterpage-20 ``` but if you click it and view it in a browser, the actual url of the image file is this: ``` http://ecx.images-amazon.com/images/I/418lsVTc0aL._SL110_.jpg ``` any idea how I can parse the image link above to get the actual jpg file using php?