php - fopen() : SSL: Connection reset by peer error in php

标签 php curl ssl libcurl fopen

我正在尝试从我的 bing 广告帐户下载报告,但遇到以下错误: 警告:fopen():SSL:连接由 xxxx 中的对等方重置... 警告:fopen():无法在 xxx 中启用加密...

      function PollGenerateReport($proxy, $reportRequestId)
      {
         // Set the request information.

         $request = new PollGenerateReportRequest();
         $request->ReportRequestId = $reportRequestId;

         return $proxy->GetService()->PollGenerateReport($request)->ReportRequestStatus;
         return $proxy->GetService()->PollGenerateReport($request)>ReportRequestStatus;
       }

      // Using the URL that the PollGenerateReport operation returned,
      // send an HTTP request to get the report and write it to the specified
      // ZIP file.
      function DownloadFile($reportDownloadUrl, $downloadPath)
      {
          if (!$reader = fopen($reportDownloadUrl, 'rb'))
           {
               throw new Exception("Failed to open URL " . $reportDownloadUrl . ".");
           }
           if (!$writer = fopen($downloadPath, 'wb'))
           {
               fclose($reader);
               throw new Exception("Failed to create ZIP file " . $downloadPath . ".");
            }
            $bufferSize = 100 * 1024;

            while (!feof($reader))
            {
                if (false === ($buffer = fread       ($reader, $bufferSize)))
                 {
                    fclose($reader);
                    fclose($writer);
                    throw new Exception("Read operation from URL failed.");
                 }
                 if (fwrite($writer, $buffer) === false)
                 {
                     fclose($reader);
                     fclose($writer);
                     $exception = new Exception("Write operation to ZIP file failed.");
                 }
              }
                 fclose($reader);
                 fflush($writer);
                 fclose($writer);
         }

因为我是 php 的新手,所以我正在寻求有关如何将 fopen() 函数(从研究来看似乎是这里的问题)转换为 curl 的任何帮助/提示。我正在使用 bing API 下载报告并在服务器上运行脚本。 谢谢。

最佳答案

我的第一个想法是 URL 可能受密码保护?

如果可能,最好导出报告,然后将其导入您的服务器。

或者查看 BING 是否有关于如何从外部访问其报告的文档,是否有 API(应用程序协议(protocol)接口(interface))?

关于php - fopen() : SSL: Connection reset by peer error in php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25545637/

相关文章:

php - alt-tab 类型的网页设计

php mysql复选框在while循环中保存

ruby-on-rails - Apache 向 Rails 提供 503 SSL 请求

php 12小时格式到24小时格式时间转换

c# - WebRequest 相当于 `curl -X DELETE ...`

linux - 运行 Linux shell 程序的 Jenkins 不接收命令

node.js - 使用预签名 URL 通过 cURL 将文件加载到 S3

ssl - SMTP 客户端如何确定是使用 Explicit 还是 Implicit SSL

c# - 在 Ubuntu 上禁用证书验证

php - PDO 有问题,但没有错误