Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 通过google drive sdk加载文档时插入图像对话框_Php_Google Drive Api - Fatal编程技术网

Php 通过google drive sdk加载文档时插入图像对话框

Php 通过google drive sdk加载文档时插入图像对话框,php,google-drive-api,Php,Google Drive Api,我正在使用php google drive sdk,并通过编程将一个文档从驱动器加载到一个div中。该文档加载正确,我可以编辑和保存而不会出现问题。当我试图通过“文档”菜单使用“插入图像”对话框时,问题出现了,它只是加载了一个空白的白色框 要获得正确的“插入图像”对话框以加载,我需要做什么,就像我直接从驱动器中使用文档一样?下面是我用来加载文档的代码: function loadDocumentForView() { $service = buildServiceAccountServi

我正在使用php google drive sdk,并通过编程将一个文档从驱动器加载到一个div中。该文档加载正确,我可以编辑和保存而不会出现问题。当我试图通过“文档”菜单使用“插入图像”对话框时,问题出现了,它只是加载了一个空白的白色框

要获得正确的“插入图像”对话框以加载,我需要做什么,就像我直接从驱动器中使用文档一样?下面是我用来加载文档的代码:

function loadDocumentForView()
{
    $service = buildServiceAccountService("Google Drive account");

    $file = $service->files->get($_SESSION['selectedDocument']);
    $name = $file->getTitle();

    $ext = strtolower(substr(strrchr($name, "."), 1));

    if ($ext == 'doc' || $ext == 'docx')
    {
        if ($_SESSION['editSelectedDocument'] == 1)
        {
            $path = "https://docs.google.com/document/d/" . $_SESSION['selectedDocument'] . "/edit?usp=sharing&embedded=true";
        }
        else
        {
            $path = "https://docs.google.com/a/googleAccount/document/d/" . $_SESSION['selectedDocument'] . "/preview";
        }
    }
    else {
        echo "Incorrect Format";
        return;
    }

    $html = "";

        if ($_SESSION['editSelectedDocument'] == 1)
        {
            $html = $html . "<div style='text-align: left; margin-right: auto; margin-left: auto; margin-bottom: 15px; width:95%;'><input driveFile='" . $_SESSION['selectedDocument'] . "' type='button' value='Save' onclick='saveChangesAndDownload(this)' style='margin-right: 5px;' fileName='" . $_SESSION['selectedDocumentName'] ."'><input currentFile='" . $_SESSION['selectedDocument'] . "' type='button' value='Exit' onclick='exitWithoutSaving(this)'>";
            $html = $html . "<span id='saveFeedbackSpan' class='serverCallResult'></span></div>";
            $html = $html . "<object data='" . $path  . "' style='text-align:       center; margin-right: auto; margin-left: auto; width:95%; height: 99%;' id='documentViewerObject' doc='" . $_SESSION['selectedDocument'] . "'></object>";
        }

    echo $html;
}
函数loadDocumentForView()
{
$service=buildServiceAccountService(“谷歌硬盘账户”);
$file=$service->files->get($\会话['selectedDocument']);
$name=$file->getTitle();
$ext=strtolower(substr(strrchr($name,“.”,1));
如果($ext==“doc”|$ext==“docx”)
{
如果($\会话['editSelectedDocument']==1)
{
$path=”https://docs.google.com/document/d/“$\u会话['selectedDocument']。/edit?usp=sharing&embedded=true”;
}
其他的
{
$path=”https://docs.google.com/a/googleAccount/document/d/“$\会话['selectedDocument']。”/preview”;
}
}
否则{
回显“格式不正确”;
返回;
}
$html=“”;
如果($\会话['editSelectedDocument']==1)
{
$html=$html.“;
$html=$html.“;
$html=$html.“;
}
echo$html;
}

我认为问题在于,“插入图像”对话框使用了一个google PickerBuilder,它使用google的域作为源,如果您查看javascript控制台,您将看到如下消息

Invalid 'X-Frame-Options' header encountered when loading 'https://docs.google.com/picker?protocol=gadgets&origin=https://docs.google.…NnhLX2lIv83439cgDPmc%22%7D))&rpctoken=hyerknnixivf&rpcService=bgxw5kefbo32': 'ALLOW-FROM https://docs.google.com' is not a recognized directive. The header will be ignored.
4080223570-picker_modularized_i18n_opc__iw.js:1008 Uncaught Error: Incorrect origin value. Please set it to - (window.location.protocol + '//' + window.location.host) of the top-most page
问题是,您需要找到一种方法来告诉选择器文档的来源是什么样的 . 我也有同样的问题,并且仍然在寻找一种方法来做到这一点