POST method and PHP ...

933 views
Skip to first unread message

Cams

unread,
Mar 11, 2010, 4:19:40 AM3/11/10
to Google Chart API
Hello !

I'm trying to use POST method in my PHP code.
I copied the example source code from this page :
http://code.google.com/intl/fr/apis/chart/docs/post_requests.html
But I've got some unexpected issues ...
In Firefox, the image doesn't display and I've got an error message :
"The image cannot be displayed beacause it contains errors."
And IE just displays some error and random characters such as :

<br />
<b>Notice</b>: fopen() [<a href='function.fopen'>function.fopen</a>]:
Content-type not specified assuming application/x-www-form-urlencoded
in <b>C:\Program Files\EasyPHP5.2.10\www\ChartsGoogle\chartserver-
image.php</b> on line <b>23</b><br />
‰PNG

IHDR XÈ »ý á bKGDÿÿÿ ½§“ IDATxœì½i”$×u øedfäV•µuõ Ѻ ± 4)Š”`I IY
¢†ò*Ó r$j;ã9öŒíñŒäñ ......

Seems like there is a problem with the headers sending in the HTTP
request, and some problems with the fopen function ...

Did anyone ever met this problem ? How to solve it ?
It maybe caused by EasyPHP or some wrong configuration ?

Thank for your help :)

Cams

unread,
Mar 15, 2010, 10:00:06 AM3/15/10
to Google Chart API
Ok, I found a solution :

juste replace the context by this one :

$context = stream_context_create(
array(
'http' => array(
'method' => 'POST',
'content' => http_build_query($chart),
'header' => "Content-Type: application/x-www-form-
urlencoded\r\n"
)
)
);

and it will work :)

Reply all
Reply to author
Forward
0 new messages