2011-02-01 3 views
-1

Так что я рабочий вариант графика, который я сделал с Charts API Google, и я выкладываю диаграммы данных/конфигурации, как это:Localhost Невозможно POST

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

Он отлично работает! Но когда я проверить это на моем локальном поле окна и попробуйте запустить его с Xampp я получаю эту ошибку:

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

Я имел взгляд на мой файл php.ini на localbox и имеет это под Еореп обертки:

; 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 

В чем проблема? Любой совет поможет Спасибо!

ответ

2

Это на самом деле отлично работает со стороны PHP. Возьмите этот URL и вставьте его в свой веб-браузер:

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

Вы получите страницу 400 Bad Request ошибки от Google говоря The Chart API request contains no valid parameters. Я ничего не знаю о API диаграмм Google, но похоже, что вы не должны правильно передавать параметры Google.

+0

@Pete - независимо от ошибки, кажется, что 'fopen' работает так, как должно, и ваши настройки PHP верны. Проблема должна быть чем-то еще в данных, которые вы отправляете в API диаграмм. –

+0

@Pete, тем не менее, код статуса [400] (http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1) указывает, что Google отклоняет ваш URL/представление. – Rudu

+0

В настоящее время это работает на сервере клиента, я сделал svn checkout из репозитория клиента, и он не работает из коробки, возможно, что-то еще проблема, потому что ребята –

Смежные вопросы