我有一個SL4哪些已經工作了幾個月的瀏覽器應用程序。截至目前,它似乎也不會再從Facebook檢索的access_token。我正在使用facebook-c#-sdk v4.1.1。有些部分的代碼下面貼:SL4 Facebook應用程序不再檢索的access_token
void FacebookLoginBrowser_Loaded(object sender, RoutedEventArgs e)
{
if (!loggedIn)
{
LoginToFacebook();
}
}
private void LoginToFacebook()
{
dynamic parms = new System.Dynamic.ExpandoObject();
parms.display = "popup";
parms.client_id = appId;
parms.redirect_uri = successUrl;
parms.cancel_url = failedUrl;
parms.scope = requestedFbPermissions;
parms.type = "user_agent";
loggingInUri = fbApp.GetLoginUrl(parms);
FacebookLoginBrowser.Source = (loggingInUri);
}
下面是瀏覽器重定向到的HTML頁面的代碼:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
Complete
</body>
<script type="text/javascript">
window.external.notify(window.location.href);
</script>
</html>
隨後的JavaScript觸發以下幾點:
private void FacebookLoginBrowser_ScriptNotify(object sender, NotifyEventArgs e)
{
if (e.Value != "Failed")
{
string url = e.Value.Replace('#', '?');
url = HttpUtility.UrlDecode(url);
Uri ur = new Uri(url);
string[] str = ur.Query.Split('&');
access_token = str[0].Split('=')[1];
if(!String.IsNullOrEmpty(access_token)){
fbApp = new FacebookApp(access_token);
App app = (App)Application.Current;
app.Fuid.fbApp = fbApp;
loggedIn = true;
loginSucceeded(e);
}
}
if (fbApp.Session == null)
{
failedLogin();
}
}
它出現通常包含值的access_token查詢字符串是不再存在。使用招,我能看到來自Facebook這確實包含價值的access_token重定向。我不確定它在哪裏丟失。讓我知道是否有人需要任何額外的信息。謝謝!