3

我是skydrive的大一新生。然后我想在 html 中使用文件选择器,并从 Interactive Live SDK 复制演示代码。但是运行结果,打开的窗口不是直接到文件选择器页面,而是直接到我的设置redirect_uri页面。那么我的演示页面有什么问题?谢谢

<script src="http://js.live.net/v5.0/wl.js" type="text/javascript"></script>

<script type="text/JavaScript">
<!--

   /////////////////////////////
    WL.init({ client_id: '$my appID', redirect_uri: 'http://www.learnyouwant.com' });

    WL.ui({
        name: "skydrivepicker",
        element: "downloadFile_div",
        mode: "open",
        select: "multi",
        onselected: onDownloadFileCompleted,
        onerror: onDownloadFileError
    });

    WL.login({ "scope": "wl.skydrive wl.signin" }).then(
        function(response) {
            openFromSkyDrive();
        },
        function(response) {
            log("Failed to authenticate.");
        }
    );

    function openFromSkyDrive() {
        WL.fileDialog({
            mode: 'open',
            select: 'single'
        }).then(
            function(response) {
                log("The following file is being downloaded:");
                log("");

                var files = response.data.files;
                for (var i = 0; i < files.length; i++) {
                    var file = files[i];
                    log(file.name);
                    WL.download({ "path": file.id + "/content" });
                }
            },
            function(errorResponse) {
                log("WL.fileDialog errorResponse = " + JSON.stringify(errorResponse));
            }
        );
    }

    function log(message) {
        var child = document.createTextNode(message);
        var parent = document.getElementById('JsOutputDiv') || document.body;
        parent.appendChild(child);
        parent.appendChild(document.createElement("br"));
    }

    function onDownloadFileCompleted(response) {
        var msg = "";
        // For each folder selected...
        if (response.data.folders.length > 0) {
            for (folder = 0; folder < response.data.folders.length; folder++) {
                // Use folder IDs to iterate through child folders and files as needed.
                msg += "\n" + response.data.folders[folder].id;
            }
        }
        // For each file selected...
        if (response.data.files.length > 0) {
            for (file = 0; file < response.data.files.length; file++) {
                // Use file IDs to iterate through files as needed.
                msg += "\n" + response.data.files[file].id;
            }
        }
        log(msg);
    };

    function onDownloadFileError(responseFailed) {
        log(responseFailed.error.message);
    }

//-->
</script>
4

1 回答 1

2

我找到了原因。redirect_uri 必须与填写应用注册相同。

于 2013-03-08T04:07:31.607 回答