Adrielpin / gchartphp

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

renderImage(true) causes E_NOTICE #27

Closed GoogleCodeExporter closed 8 years ago

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

What is the expected output? What do you see instead?
An unexpected error has occured with the following information:
(8): fopen() [function.fopen]: Content-type not specified assuming 
application/x-www-form-urlencoded
(654): gChart.php

What version of the product are you using? On what operating system?
r44, XAMPP, PHP 5.3, Windows 7 64 Bit

Please provide any additional information below.

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

GoogleCodeExporter commented 8 years ago
Fix it by adding 
'header' => 'Content-type: application/x-www-form-urlencoded'."\r\n" to the 
stream_context_create

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:47