SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2005
    Location
    UK
    Posts
    539
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to cache google chart using POST request method

    I'm calling my php script that generates the google chart (POST method http://code.google.com/apis/chart/do..._requests.html) and has this code to output the image (the page is set to png output):

    $context = stream_context_create(
    array('http' => array(
    'method' => 'POST',
    'content' => http_build_query($chart))));
    fpassthru(fopen($url, 'r', false, $context));

    I call the script as an image (...img src="gchart.php?.....)

    All works fine, but i'd like to cache the results of the above, how can i capture the output of post request and store as png file?

  2. #2
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can't you just capture the response from fopen and use file_put_contents to save it as a PNG, then render your <img> tag to point to that file?

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,810
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by skyline View Post
    but i'd like to cache the results of the above, how can i capture the output of post request and store as png file?
    Caching POST results doesn't make sense since using POST implies that the info returned is expected to change between calls. That is what POST is for - if you know the data will always stay the same then you should be using GET so that the browser will know it is allowed to cache the results.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •