其他端口上的file_get_contents [英] file_get_contents on other port

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

问题描述

我必须通过80与其他端口上的服务联系,但是函数file_get_contents()返回错误:无法打开流:连接被拒绝

I must contact services rest on different ports by 80, but the function file_get_contents () returns an error: failed to open stream: Connection refused

$url = "http://nexusdigital.agency:81/API/....";

$result = file_get_contents($url, false);

如何配置其他端口上的读数?

How can I configure the reading on other ports?

推荐答案

使用CURL:

<?php
$curl = curl_init('http://nexusdigital.agency/API/....'); 
curl_setopt($curl, CURLOPT_PORT, 81); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 81); 
$result = curl_exec($curl);
?>

这篇关于其他端口上的file_get_contents的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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