Alright, what I'm trying to do is grab an image from a remote webpage, and display it (After doing some modifications with the GD Library, but I have that working already).
Anyways, I would simply use something like this:
$im = imageCreateFromPng("http://www.testserver.com/webstats.php");
header("Content-type: image/png");
imagePng($im);
However, the website requires a login to view the image!
So, my next idea was to log in through cURL:
$cookie = "My working cookie here!";
geturl("http://www.testserver.com/webstats.php", $cookie);
echo $return;
function geturl($url, $cookie)
{
global $return;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_GET, 1);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
ob_start();
$return = curl_exec($ch);
ob_end_clean();
if (!$return) echo "(curl_exec returned FALSE, ".curl_error($ch).")<br>";
curl_close($ch);
}
This worked fine for getting the image, however, I cannot load it into GD to edit it!
When I try loading it ($return) to a PNG, I get this error:
Warning: imagecreatefrompng(‰PNG ): failed to open stream: No such file or directory in /home/xxxxxxx/public_html/xxxxxx/index.php on line 5
So, any ideas?
The PHP file generates a png image on-the-fly using the GD Library, and that is all that is outputted.
Thanks!