我有一个代码,它使用它的 api 在 Skydrive 中创建新文件夹。它实际上工作。但它总是创建具有相同名称的文件夹。因为文件夹的名称是硬编码的。
我的问题是如何将文本框绑定到 API 调用,以便它将用户指定的文件夹名称传递给 API
这是创建文件夹的代码:
<script src="//js.live.net/v5.0/wl.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript" language="javascript">
function createFolder_onClick() {
WL.login({
scope: "wl.skydrive_update"
}).then(
function (response) {
WL.api({
path: "me/skydrive",
method: "POST",
body: {
"name": "This is a new folder",
"description": "A new folder"
}
}).then(
function (response) {
document.getElementById("infoArea2").innerText =
"Created folder. Name: " + response.name + ", ID: " + response.id;
},
function (responseFailed) {
document.getElementById("infoArea2").innerText =
"Error calling API: " + responseFailed.error.message;
}
);
},
function (responseFailed) {
document.getElementById("infoArea2").innerText =
"Error signing in: " + responseFailed.error_description;
}
);
}
</script>