Adrielpin / gchartphp

Automatically exported from code.google.com/p/gchartphp
0 stars 0 forks source link

http_build_query causes errors on some php configs #26

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Make a valid chart
2. call $chart->renderImage(true);

What is the expected output? What do you see instead?
A rendered chart

What version of the product are you using? On what operating system?
400 bad request

Please provide any additional information below.
On some PHP configs the http_build_query has different default value to its 
arguments (I.E. XAMPP),
You should use http_build_query($this->chart, '', '&') instead

Original issue reported on code.google.com by Peta...@gmail.com on 12 Aug 2010 at 3:28

GoogleCodeExporter commented 8 years ago
Sorry i got the order of info mixed up

Original comment by Peta...@gmail.com on 12 Aug 2010 at 3:33

GoogleCodeExporter commented 8 years ago
    public function renderImage($post = false) {
            header('Content-type: image/png');
            if ($post) {
                $this->setDataSetString();
                $url = 'http://chart.apis.google.com/chart?chid=' . md5(uniqid(rand(), true));
                $context = stream_context_create(
                                array('http' => array(
                                        'method' => 'POST',
                                        'header' => 'Content-type: application/x-www-form-urlencoded' . "\r\n",
                                        'content' => urldecode(http_build_query($this->chart, '', '&')))));
                fpassthru(fopen($url, 'r', false, $context));
            } else {
                $url = str_replace('&', '&', $this->getUrl());
                readfile($url);
            }
        }

Original comment by Peta...@gmail.com on 12 Aug 2010 at 3:34

GoogleCodeExporter commented 8 years ago
Hello,
I merged your code in r49.
Let me know of you have any more problems.

Thank you for your improvements to the project!

Original comment by bardellie on 16 Aug 2010 at 12:46