When my PHP script runs, I would like to run a link like this server side:
http://77.33.xx.xx/s/addtoqueue.php?action=store&filename=myprettypicture&link=http://i69.servimg.com/u/f69/13/29/70/44/facebo10.png
Im doing this for storing the images on a own separate images server. The link is adding the image to a queue.
How can I execute this link correct?
I did this so far:
$link = 'http://77.33.xx.xx/s/addtoqueue.php?action=store&filename='.$filename.'&link=$link;
But dont know how to run this?
And would it by the way be smart to urlencode() and urldecode() the $link?
I wouldn’t build the query string myself like that, but use
http_build_query()in preference:To actually make a call to the URL you can use a number of techniques, but my favourite in this case would be curl. Here is an adapted version of the example from the manual:
Other options include
file_get_contents($link);if the fopen wrappers have been enabled.Additional response for comments
$responsenow contains the response from the URL. From thecurl_exec()manual page:For more information on the curl options you can use checkout the
curl_setopt()manual page.