gpt4 book ai didi

javascript - 将用户登录到 OneDrive

转载 作者:行者123 更新时间:2023-12-03 11:09:32 24 4
gpt4 key购买 nike

我想检查用户是否已经登录到 OneDrive,如果没有,则允许他们登录。我首先在 JS/HTML 项目中尝试过此操作。然后使用 C#/XAML 项目。

我查看了 C#/XAML OneDrive 代码 here而且它似乎更容易理解,所以我用它创建了一个项目,却得到了错误:

error CS0103: The name 'updateUI' does not exist in the current context
  • JS/HTML 项目问题(见此行下方)已解决,但我想知道是否有人知道如何解决 C# 错误。
<小时/>

对于 JS/HTML 项目,我遵循代码 here将其添加到default.js文件中:

WL.init({ scope: ["wl.signin", "wl.skydrive"] }).then(
function (result) {
if (result.status == "connected") {
//display to the user, that they are connected
}
else {
// Display the sign-in button.
connectButton.style.display = "block";
connectButton.onclick = function () {
WL.login({
scope: ["wl.signin", "wl.skydrive"]
}).then(
function (result) {
if (result.status == "connected") {
// Don't display the sign-in button.
connectButton.style.display = "none";
//display to the user, that they are connected
}
}
);
};
}
});

并包含这是default.html header :

<script src="///LiveSDKHTML/js/wl.js"></script>

这在default.html正文中:

<button id="connectButton" style="display:none">
Connect with a Microsoft account</button>

但是,运行该应用程序后,似乎没有任何反应。我什至将 JavaScript 更改为这样,只是为了确保正确调用该函数,但什么也没发生。没有背景变化(是的,我包含了 jQuery 并且它在 WL.init 调用之外工作):

WL.init({ scope: ["wl.signin", "wl.skydrive"] }).then(
function (result) {
if (result.status == "connected") {
$('body').css('background-clor', 'blue');
}
else {
$('body').css('background-clor', 'red');
}
});

最佳答案

在代码中放入一些 console.log 或警报。看看是否有返回。如果你不这样做,你可能会错过一些东西。也尝试使用 session 函数(WL.getSession)。

例如,我读过有关 Live SDK v5.6 的内容并注意到这一点:Live SDK 必须安装在您的计算机上。

关于javascript - 将用户登录到 OneDrive,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27673793/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com