因此,我使用Google Charts API制作了图表的工作版本,并发布了图表数据/配置,如下所示:
$context = stream_context_create(
array('http' => array(
'method' => 'POST',
'content' => http_build_query($chart))));
fpassthru(fopen($url, 'r', false, $context));
效果很好!但是,当我在我的本地Windows框中检查它并尝试使用Xampp运行时,我收到此错误:
警告: FOPEN(http://chart.apis.google.com/chart?chid=982f36) [function.fopen]:无法打开 stream:HTTP请求失败! HTTP / 1.0 400错误请求 C:\ XAMPP \ htdocs中\图表\ image.php 在第226行
我看过localbox上的php.ini文件,它在fopen包装器下有这个:
; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
; http://php.net/allow-url-fopen
allow_url_fopen = On
; Whether to allow include/require to open URLs (like http:// or ftp://) as files.
; http://php.net/allow-url-include
allow_url_include = Off
; Define the anonymous ftp password (your email address). PHP's default setting
; for this is empty.
; http://php.net/from
;from="john@doe.com"
; Define the User-Agent string. PHP's default setting for this is empty.
; http://php.net/user-agent
;user_agent="PHP"
; Default timeout for socket based streams (seconds)
; http://php.net/default-socket-timeout
default_socket_timeout = 60
; If your scripts have to deal with files from Macintosh systems,
; or you are running on a Mac and need to deal with files from
; unix or win32 systems, setting this flag will cause PHP to
; automatically detect the EOL character in those files so that
; fgets() and file() will work regardless of the source of the file.
; http://php.net/auto-detect-line-endings
;auto_detect_line_endings = Off
这可能是什么问题?任何建议都有帮助谢谢!
答案 0 :(得分:2)
实际上从PHP方面工作得很好。获取该URL并将其粘贴到您的Web浏览器中:
http://chart.apis.google.com/chart?chid=982f36
您将收到来自Google的400 Bad Request
错误页面The Chart API request contains no valid parameters
。我对Google图表API一无所知,但您似乎无法正确地将参数传递给Google。