0

我正在尝试使用 http_get 调用 PHP 中的页面:

$url = "http://mysite.fr:9090/neolane-webservice/campagnesclient/Coclico=1135446";
http_get($url, $appelOptions, $appelInfos);

我的问题是它每次都不起作用。

我安装了 Wireshark 来查看我真正发送的内容,我发现了一件奇怪的事情。有时,该端口不用于 HTTP 请求。

当它起作用时,我有:

Hypertext Transfer Protocol
GET http://mysite.fr:9090/neolane-webservice/campagnesclient/Coclico=1135446 HTTP/1.1\r\n
    Request Method: GET
    Request URI: http://mysite.fr:9090/neolane-webservice/campagnesclient/Coclico=1135446
    Request Version: HTTP/1.1
User-Agent: PECL::HTTP/1.6.5 (PHP/5.2.4-2ubuntu5.7)\r\n
Host: mysite.fr:9090\r\n
Pragma: no-cache\r\n
Accept: */*\r\n
Proxy-Connection: Keep-Alive\r\n
Keep-Alive: 300\r\n
Connection: keep-alive\r\n
Date: Fri, 15 Jun 2012 16:40:46 +0200\r\n
Accept-Charset: utf-8\r\n
Accept-Encoding: gzip;q=1.0,deflate;q=0.5\r\n
\r\n

当它不是时:

Hypertext Transfer Protocol
GET http://mysite.fr:9090/neolane-webservice/campagnesclient/Coclico=1135446 HTTP/1.1\r\n
    Request Method: GET
    Request URI: http://mysite.fr:9090/neolane-webservice/campagnesclient/Coclico=1135446
    Request Version: HTTP/1.1
User-Agent: PECL::HTTP/1.6.5 (PHP/5.2.4-2ubuntu5.7)\r\n
Host: mysite.fr\r\n
Pragma: no-cache\r\n
Accept: */*\r\n
Proxy-Connection: Keep-Alive\r\n
Keep-Alive: 300\r\n
Connection: keep-alive\r\n
Date: Fri, 15 Jun 2012 16:40:34 +0200\r\n
Accept-Charset: utf-8\r\n
Accept-Encoding: gzip;q=1.0,deflate;q=0.5\r\n
\r\n

我尝试使用 wget 调用该页面,并且它始终有效:

wget http://mysite.fr:9090/neolane-webservice/campagnesclient/Coclico=1135446

所以我猜我的问题是由于 Apache 配置造成的,但我不知道去哪里找。请问你能帮帮我吗 ?

4

1 回答 1

0

您需要在$appelOptions阵列中设置端口。

$appelOptions['port']=9090;
http_get($url, $appelOptions, $appelInfos);

不幸的是http_get,似乎不尊重 URL 中的 :port 语法

于 2012-07-05T19:45:53.713 回答