I have a script which generates Google Chart images for clients. It works fine displaying in HTML but I now need to save each chart locally as a .png.
If I try:
$imageData = file_get_contents($url);
then I always receive
[function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400
The script works fine for normal images, but not Google charts. Same result if I use cURL to save the image too.
An example of my Google chart $url is below. I've hexed out the colons and pipe symbols but it did not fix the issue:
<?php $ch = curl_init("www.example.com/curl.php?option=test"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); echo $output; ?>Answer2:
I managed to get this to work in the end - it seems the spaces in the label names were causing errors, replacing with %20 did the trick