我正在尝试从我的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(应用协议接口)?
关于php - fopen():SSL:php中的对等错误导致连接重置,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25545637/