【发布时间】:2020-09-13 12:24:34
【问题描述】:
我有一些这样的http请求
$url = 'https://example.com/authentication';
$data = array('email' => 'value1', 'password' => 'value2');
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }
var_dump($result);
但是我遇到了这样的错误 警告:file_get_contents(https://example.com/authentication):无法打开流:连接被拒绝
我读到 curl 可以提供帮助,但我不知道如何实现它,在此先感谢
【问题讨论】:
-
这不是客户端错误,它与服务器有关。请在终端中运行此命令
telnet SERVER_IP_OR_URL 443