本地主机无法 POST

发布于 2024-10-15 22:24:22 字数 1819 浏览 1 评论 0原文

因此,我有使用 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]:打开失败 流:HTTP 请求失败! HTTP/1.0 400 错误请求 C:\xampp\htdocs\graph\image.php 第226行

我查看了本地盒子上的 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="[email protected]"

; 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

这里可能有什么问题?任何建议都会有帮助谢谢!

So I have working version of a graph that I made with the Google Charts API, and I post the Chart data/configuration like this:

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

It works great! But when I check it out on my local windows box and try to run it with Xampp I get this error:

Warning:
fopen(http://chart.apis.google.com/chart?chid=982f36)
[function.fopen]: failed to open
stream: HTTP request failed! HTTP/1.0
400 Bad Request in
C:\xampp\htdocs\graph\image.php
on line 226

I have had a look at my php.ini file on the localbox and it has this under fopen wrappers:

; 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="[email protected]"

; 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

What could be the problem here? Any advice would help Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

决绝 2024-10-22 22:24:22

实际上,从 PHP 端来看,它运行得很好。获取该网址并将其粘贴到您的网络浏览器中:

http://chart.apis.google。 com/chart?chid=982f36

您会收到来自 Google 的 400 Bad Request 错误页面,提示 Chart API 请求不包含有效参数。我对 Google 图表 API 一无所知,但看来您一定没有正确地将参数传递给 Google。

It's actually working just fine from the PHP side. Take that URL and paste it into your web browser:

http://chart.apis.google.com/chart?chid=982f36

You'll get a 400 Bad Request error page from Google saying The Chart API request contains no valid parameters. I don't know anything about the Google charts API, but it seems like you must not be passing the parameters to Google correctly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文