PHP:当其他人成功时,PATCH 方法会失败



我有一个API我正在使用各种方法。GET和我正在测试的其他方法一样工作正常。使用 PATCH 时,尽管文档显示它已启用,但它还是会给出错误。

错误是:

Warning: file_get_contents(): SSL: Connection reset by peer in upload.php on line 20
Warning: file_get_contents(https://api-domain/answers/331): failed to open stream: HTTP request failed! in oracle_upload.php on line 20
Error

第 20 行是

$response = file_get_contents('https://api-domain/answers/331', FALSE, $content)

至于$content变量:

$postData = array(        
    'solution' => 'Testing 123'
);
$context = stream_context_create(array(
    'http' => array(
        'method' => 'PATCH',
        'header' => "Authorization: Basic dXNlcjpwYXNzrnContent-Type: application/jsonrn",
        'content' => json_encode($postData)
    ),
    "ssl"=>array(
        "allow_self_signed"=>true,
        "verify_peer"=>false,
        "verify_peer_name"=>false
    )
));

请注意,https://api-domain 是假的 addy谢谢

在你的 php.ini 文件中更改此行或添加。

extension=php_openssl.dll

allow_url_fopen = On

最新更新