无法打开流:连接被拒绝的PHP

时间:2020-05-26 16:09:40

标签: php curl https

我有一些这样的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可以帮上忙,但是我不知道如何实现它,请先感谢

1 个答案:

答案 0 :(得分:0)

尝试此基本卷曲请求

procman