簡體   English   中英

fopen():SSL:php中的對等錯誤重置連接

[英]fopen(): SSL: Connection reset by peer error in php

我正在嘗試從我的Bing Ads帳戶下載報告,遇到以下錯誤:警告: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(應用協議接口)?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM