【问题标题】:Localhost Unable to POST本地主机无法发布
【发布时间】:2011-02-01 15:58:18
【问题描述】:

所以我有一个使用 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 行

我在 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

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

【问题讨论】:

    标签: php xampp fopen


    【解决方案1】:

    它实际上在 PHP 方面工作得很好。获取该 URL 并将其粘贴到您的网络浏览器中:

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

    您会从 Google 收到一个 400 Bad Request 错误页面,上面写着 The Chart API request contains no valid parameters。我对 Google 图表 API 一无所知,但您似乎不能正确地将参数传递给 Google。

    【讨论】:

    • @Pete - 无论从错误来看,fopen 似乎都在正常工作,并且您的 PHP 设置是正确的。问题一定出在您发布到图表 API 的数据中。
    • @Pete 永远不会少,400 的状态代码表示 Google 拒绝您的网址/提交。
    • 这目前正在客户端的服务器上工作,我从客户端的存储库中进行了 svn 签出,但它不能开箱即用,也许是其他问题谢谢大家
    猜你喜欢
    • 2020-02-17
    • 1970-01-01
    • 2012-03-22
    • 1970-01-01
    • 2020-12-15
    • 2017-02-08
    • 1970-01-01
    • 2021-12-27
    • 2012-10-27
    相关资源
    最近更新 更多