can anyone help me. what script used and how?
i have found a link which can open youtube video by putting video id in url address.
i want to do same thing with imgur.com . i want to open imgur image in my own php page by image id.
is it possible?
currently i have a script that open image in my own php page but it shows full url of imgur.com
current script localhost.com/image.php?url=http://i.imgur.com/Zw7JFTD.jpg
i want to open something like this . So people can not see image full url in address bar.
localhost.com/image.php?id=Zw7JFTD
First method
You have to use cURL
In file imgur.php
, write something like
$curl = curl_init('http://i.imgur.com/'.$_GET['id'].'.jpg');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
header('Content-Type: image/jpeg');
echo curl_exec($curl);
This is very basic code and might not work and I can't test it now
Second method
But if you don't want to download image server-side, do something like:
<img src="<?php echo 'http://i.imgur.com/'.$_GET['id'].'.jpg'; ?>"/>
Third method
You can use redirect:
header('HTTP/1.1 307 Temporary Redirect');
header('Location: '.'http://i.imgur.com/'.$_GET['id'].'.jpg');
It makes sense only when image isn't accessing directly
Yes, you would simply add http://i.imgur.com/
and .jpg
to the end of the URL.
echo 'http://i.imgur.com/' . $_GET['id'] .'.jpg';