Google Charts Through CURL

Posted by swt83 on Stack Overflow See other posts from Stack Overflow or by swt83
Published on 2010-03-27T02:44:52Z Indexed on 2010/03/27 2:53 UTC
Read the original article Hit count: 671

Filed under:
|
|

I have a PHP class that helps me generate URLs for custom charts using Google Chart service. These URLs work fine when I load them in my browser, but I'm trying to pull them using CURL so I can access the charts on secure https websites. Whenever I try and pull a chart via CURL, I get an Error 400 Bad Request. Any idea on how to get around this? Everything I have tried has failed.

    $url = urldecode($_GET['url']);

    $session = curl_init($url);                    // Open the Curl session
    curl_setopt($session, CURLOPT_HEADER, false);          // Don't return HTTP headers
    curl_setopt($session, CURLOPT_RETURNTRANSFER, true);   // Do return the contents of the call
    $image = curl_exec($session);                            // Make the call
    #header("Content-Type: image/png");                  // Set the content type appropriately
    curl_close($session); // And close the session
    die($image);

© Stack Overflow or respective owner

Related posts about php

Related posts about curl