duan010167787 2014-11-22 18:19
浏览 68

Onenote API PHP - 尝试发布多个PHP文件,submit.php返回空白页面

I’m having some issues with modifying the sample PHP code from the Outlook API PHP code to iterate through a series of PHP files to post. I have the Client ID, Secret, and callback URL in the file correctly.

I’ve modified the code as follows:

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);
    }

Later in the same file:

        case "file":
            $pdffiles = glob('*.{pdf,PDF}', GLOB_BRACE);
            foreach($pdfiles as $pdffile) {
                $OneNoteRequest->createPageWithFile($pdffile);
              }
            break;

Ideas?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c