无法访问skyDrive文件夹

时间:2013-02-09 02:21:17

标签: javascript onedrive

我正在尝试创建一个应用程序,它将通过SkyDrive API访问文件夹及其内容。

但只有我能得到的东西才是我的名字和图片。文件夹没有被描述出于某些未知原因。

代码运行没有错误只有输出不存在。我真的不知道我做错了什么。如果有人有任何建议我会非常感激。

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>file Content</title>
    <style>

    </style>    

</head>
<body>
<h1>File Content</h1>
<div>
  <div id="meName" class="Name"></div>
  <div id="meImg"></div>
  <div id="signin"></div>
  <div bgcolor='blue' id ="meCount"></div>
</div>


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

    // Update the following values
    var client_id = "XXXXXXXXXX",
        scope = ["wl.signin", "wl.basic", "wl.offline_access", "wl.emails", "wl.skydrive_update"],
        redirect_uri = "http://XXXXXXXX/callback.aspx";

    function id(domId) {
        return document.getElementById(domId);
    }

    function displayMe() {
        var imgHolder = id("meImg"),
        nameHolder = id("meName"),
    cout = id("meCount");

        if (imgHolder.innerHTML != "") return;

        if (WL.getSession() != null) {
            WL.api({ path: "me/picture", method: "get" }).then(
                    function (response) {
                        if (response.location) {
                            imgHolder.innerHTML = "<img src='" + response.location + "' />";
                        }
                    }
                );



            WL.api({ path: "me", method: "get" }).then(
                    function (response) {
                        nameHolder.innerHTML = response.name;
                    }
                );

            WL.api({ path: "me/skydrive", method: "get" }).then(
                    function (response) {
                        cout.innerHTML = response.count;
                    }
                );


        }
    }



    function clearMe() {
        id("meImg").innerHTML = "";
        id("meName").innerHTML = "";
    }

    WL.Event.subscribe("auth.sessionChange",
        function (e) {
            if (e.session) {
                displayMe();
                refreshPath ();
            }
            else {
                clearMe();
            }
        }
    );




    WL.init({ client_id: client_id, redirect_uri: redirect_uri, 
              response_type: "code" });

    WL.ui({ name: "signin", element: "signin", brand: "skydrive", 
            type: "Connect", scope: "wl.signin wl.skydrive_update" });



    function refreshPath (){
                  var options = viewerPage.options;

                  var name = (options && 'name' in options) ? 
                                              options.name : 'SkyDrive';
                  var path = (options && 'path' in options) ? 
                                              options.path : 'me/skydrive';

                  loadPath(name, path);
                }

                function isFolder (file){
                  return file.type == 'folder' || 
file.type == 'album';
                }

                function loadPath(name, path){
                 updateTitle(name);
                 clearViewer();

         WL.api({path: path + '/files'}, function (response){
                  if (response.error){
                  return;
                  }

             var items = response.data.map(function (item) {

                  return{
                    group: 'default',
                    key: item.id,
                    file: item
                    };
                });

                items.sort(function itemA, itemB){
                   var isFolderA = isFolder(itemA.file);
                   var isFolderB = isFolder(itemB.file);

                   if (isFolderA == isFolderB){

return itemA.file.namelocaleCompare(itemB.file.name);
                    }
                    else if (isFolderA){
                    return -1;
                    }
                    else{
                      return 1;
                      }
                    });
                viewerPage.items = items;
                updateList();
            });
            }




    </script>

<script>

</script>
</body>
</html>

2 个答案:

答案 0 :(得分:1)

您是否尝试过在ISDK上播放样本:

http://isdk.dev.live.com

例如,以下示例:

http://isdk.dev.live.com/ISDK.aspx?category=scenarioGroup_skyDrive&index=2

还有一个面板,您可以通过直接调用Live API服务来查看它们返回的内容。

答案 1 :(得分:1)

BTW,这是Live SDK开发者论坛的链接:

http://social.msdn.microsoft.com/Forums/en-US/messengerconnect/threads