我在修改Outlook API PHP代码中的示例PHP代码时遇到了一些问题,需要迭代一系列PHP文件才能发布。我正确地在文件中有客户端ID,密码和回调URL。
我修改了代码如下:
submit.php:
function createPageWithFile($pdffile)
{
$ch = $this->initCurl();
//ISO 8601 standard time stamp
$date = date('c');
//Read the file into memory
//Note that reading entire large files into memory could create problems if
// PHP doesn't have enough memory to work with
$fileContents = file_get_contents($pdffile);
//Includes the Presentation part and embedded file data part
//Each has its own Content-Disposition and Content-Type headers
//The request must end with a blank line to be a valid Multipart request
$postdata = <<<POSTDATA
--{$this->boundary}
Content-Disposition: form-data; name="Presentation"
Content-Type: text/html
<!DOCTYPE html>
<html>
<head>
<title>A page created with a file attachment (PHP Sample)</title>
<meta name="created" value="$date"/>
</head>
<body>
<h1>This is a page with a PDF file attachment</h1>
<object
data-attachment="$pdffile"
data="name:embeddedFile"
type="application/pdf" />
<img data-render-src="name:embeddedFile" alt="$pdffile" width="1500" />
</body>
</html>
--{$this->boundary}
Content-Disposition: form-data; name="embeddedFile"
Content-Type: application/pdf
$fileContents
--{$this->boundary}--
POSTDATA;
curl_setopt($ch,CURLOPT_POSTFIELDS,$postdata);
$response = curl_exec($ch);
$this->finish($ch,$response,$pdffile);
}
稍后在同一档案中:
case "file":
$pdffiles = glob('*.{pdf,PDF}', GLOB_BRACE);
foreach($pdfiles as $pdffile) {
$OneNoteRequest->createPageWithFile($pdffile);
}
break;
想法?