php卷曲问题 [英] php curl problem

查看:200
本文介绍了php卷曲问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用curl获取远程文件的信息。问题是其他Web服务器在端口81上。

I am trying to get information of remote file with curl. Problem is that other web-server is on port 81.

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt ($ch, CURLOPT_PORT , 81);
curl_setopt($ch, CURLOPT_URL, 'http://98.246.25.185/server_status2.php');
$store = curl_exec ($ch);
echo substr($store, 1);
curl_close ($ch);
?>

并且你可以看到它不工作。

And as you can see it doesnt work.

推荐答案

如果在URI中指定端口号,会发生什么?

What happens if you specify the port number in the URI ?

我的意思是先删除 CURLOPT_PORT 行,然后修改 CURLOPT_URL 一行以添加端口号:

What I mean is first remove the CURLOPT_PORT line, and, then, modify the CURLOPT_URL one to add the port number :

curl_setopt($ch, CURLOPT_URL, 'http://98.246.25.185:81/server_status2.php');



在注释后编辑:我只是尝试这部分代码:


Edit after the comment : I just tryied this portion of code :

$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, true);
//curl_setopt ($ch, CURLOPT_PORT , 81);
curl_setopt($ch, CURLOPT_URL, 'http://98.246.25.185:81/server_status2.php');
$store = curl_exec ($ch);
echo substr($store, 1);
curl_close ($ch);

我得到这个输出:

Online Peak: 59
Online: 17
Distributive server: Online
Agent server: Online

所以,代码似乎没问题。

So, the code seems to be OK.

你确定没有防火墙或任何东西,您的网络,阻止您对该服务器的端口81执行HTTP请求?

在浏览器中键入该URI时是否有效?

Are you sure there is not a firewall or anything or your network, that prevents you from doing HTTP requests on port 81 to that server ?
Does it work when you type that URI in your browser ?

这篇关于php卷曲问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆