English 中文(简体)
PHP Proxy服务器和JSON密码问题?
原标题:PHP Proxy Server and Calling JSON Code Problem?

以下网站。 我正在使用其中一项答复中提供的守则。

该守则是:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>



<?php

$server_url = "http://www.nfl.com/liveupdate/scorestrip/ss.json";

$options = array
(
    CURLOPT_HEADER         => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_TIMEOUT        => 60,
    CURLOPT_CONNECTTIMEOUT => 0,
    CURLOPT_HTTPGET        => 1
);

$service = $_GET["service"];

$request_headers = Array();
foreach($_SERVER as $i=>$val) {
        if (strpos($i,  HTTP_ ) === 0) {
                $name = str_replace(array( HTTP_ ,  _ ), array(  ,  - ), $i);
                if ($name !=  HOST )
                {
                    $request_headers[] = "{$name}: {$val}";
                }
        }
}

$options[CURLOPT_HTTPHEADER] = $request_headers;

switch (strtolower($_SERVER["REQUEST_METHOD"]))
{

    case "post":
        $options[CURLOPT_POST] = true;
        $url = "{$server_url}/services/".$service;

        $options[CURLOPT_POSTFIELDS] = file_get_contents("php://input");

        break;
    case "get":

        unset($_GET["service"]);

        $querystring = "";
        $first = true;
        foreach ($_GET as $key => $val)
        {
            if (!$first) $querystring .= "&";
            $querystring .= $key."=".$val;
            $first = false;
        }

        $url = "{$server_url}/services/".$service."?".$querystring;

        break;
    default:
        throw new Exception("Unsupported request method.");
        break;

}

$options[CURLOPT_URL] = $url;

$curl_handle = curl_init();

curl_setopt_array($curl_handle,$options);
$server_output = curl_exec($curl_handle);
curl_close($curl_handle);

$response = explode("

",$server_output);
$headers = explode("
",$response[0]);

foreach ($headers as $header)
{
    if ( !preg_match( ;^transfer-encoding:;ui , Trim($header))  )
    {
        header($header);
    }
}

echo $response[1]; 


?> 



</body>
</html>

不幸的是,我犯了以下错误,原因何在?

Warning: Cannot modify header information - headers already sent by (output started at C:inetpubvhostsallencoded.comhttpdocs est.php:12) in C:inetpubvhostsallencoded.comhttpdocs est.php on line 88 Warning: Cannot modify header information - headers already sent by (output started at C:inetpubvhostsallencoded.comhttpdocs est.php:12) in C:inetpubvhostsallencoded.comhttpdocs est.php on line 88 Warning: Cannot modify header information - headers already sent by (output started at C:inetpubvhostsallencoded.comhttpdocs est.php:12) in C:inetpubvhostsallencoded.comhttpdocs est.php on line 88 Warning: Cannot modify header information - headers already sent by (output started at C:inetpubvhostsallencoded.comhttpdocs est.php:12) in C:inetpubvhostsallencoded.comhttpdocs est.php on line 88 Warning: Cannot modify header information - headers already sent by (output started at C:inetpubvhostsallencoded.comhttpdocs est.php:12) in C:inetpubvhostsallencoded.comhttpdocs est.php on line 88 Warning: Cannot modify header information - headers already sent by (output started at C:inetpubvhostsallencoded.comhttpdocs est.php:12) in C:inetpubvhostsallencoded.comhttpdocs est.php on line 88 Warning: Cannot modify header information - headers already sent by (output started at C:inetpubvhostsallencoded.comhttpdocs est.php:12) in C:inetpubvhostsallencoded.comhttpdocs est.php on line 88 Warning: Cannot modify header information - headers already sent by (output started at C:inetpubvhostsallencoded.comhttpdocs est.php:12) in C:inetpubvhostsallencoded.comhttpdocs est.php on line 88 Warning: Cannot modify header information - headers already sent by (output started at C:inetpubvhostsallencoded.comhttpdocs est.php:12) in C:inetpubvhostsallencoded.comhttpdocs est.php on line 88 HTTP/1.1 404 Not Found Server: Apache Content-Type: text/html; charset=iso-8859-1 Content-Encoding: gzip Content-Length: 224 Cache-Control: max-age=7146 Expires: Sat, 13 Aug 2011 22:12:11 GMT Date: Sat, 13 Aug 2011 20:13:05 GMT Connection: keep-alive Vary: Accept-Encoding X-Akamai-Edgescape: country_code=US

最佳回答

您不能在打电话<条码>标题之前重复任何内容。 因此,在您的开放点前,其一切 st。

您的最好用心是,在您的开幕前,在您的开幕前,在您的开幕前,在您的开幕前,在您的开幕前,在座标上,将尽其所能。

问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签