internal static void ShowAppRequestDialogViaBrowser() { var task = Task.Run(async() => await AppAuthenticationHelper.GetFacebookConfigValue("Facebook", "AppId")); task.Wait(); Launcher.LaunchUriAsync(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/apprequests?access_token={0}&redirect_uri=fb{2}%3A%2F%2Fsuccess&app_id={1}&message=YOUR_MESSAGE_HERE&display=touch", Session.ActiveSession.CurrentAccessTokenData.AccessToken, task.Result, task.Result))); }
internal static void ShowFeedDialogViaBrowser(string toId = "", string link = "", string linkName = "", string linkCaption = "", string linkDescription = "", string picture = "") { var task = Task.Run(async() => await AppAuthenticationHelper.GetFacebookConfigValue("Facebook", "AppId")); task.Wait(); Launcher.LaunchUriAsync(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/feed?access_token={0}&redirect_uri={2}&app_id={1}&display=touch&to={3}&link={4}&name={5}&caption={6}&description={7}&picture={8}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, task.Result, Session.FeedRedirectUri, toId, link, linkName, linkCaption, linkDescription, picture))); }
public void ShowFeedDialog() { LifecycleHelper.OnDialogDismissed = null; LifecycleHelper.OnDialogDismissed += DismissDialogWhenDone; var task = Task.Run(async() => await AppAuthenticationHelper.GetFacebookConfigValue("Facebook", "AppId")); task.Wait(); dialogWebBrowser.Navigate(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/feed?access_token={0}&redirect_uri=fb{2}%3A%2F%2Fsuccess&app_id={1}&display=touch", Session.ActiveSession.CurrentAccessTokenData.AccessToken, task.Result, task.Result))); }
internal static void ShowAppRequestDialogViaBrowser(string message, string title, List <string> idList, string data) { var task = Task.Run(async() => await AppAuthenticationHelper.GetFacebookConfigValue("Facebook", "AppId")); task.Wait(); var idBuilder = new StringBuilder("&to="); if (idList != null) { foreach (var id in idList) { idBuilder.Append(id + ","); } } Launcher.LaunchUriAsync(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/apprequests?access_token={0}&redirect_uri={2}&app_id={1}&message={5}&display=touch{3}&title={4}&data={6}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, task.Result, Session.AppRequestRedirectUri, idBuilder.Length > 4 ? idBuilder.ToString() : String.Empty, title, message, data))); }
/// <summary> /// Maps a deep link Uri to a navigation within this application /// </summary> /// <param name="uri">Deep link Uri to map</param> /// <returns>Navigation Uri within this app</returns> public override Uri MapUri(Uri uri) { bool response = Task.Run(() => AppAuthenticationHelper.IsFacebookLoginResponse(uri)).Result; // if URI is a facebook login response, handle the deep link (once per invocation) if (response) { FacebookSession session = new FacebookSession(); try { session.ParseQueryString(HttpUtility.UrlDecode(uri.ToString())); // Handle success case // do something with the custom state parameter if (session.State != "custom_state_string") { MessageBox.Show("Unexpected state: " + session.State); } else { // save the token and continue (token is retrieved and used when the app is lauched) SessionStorage.Save(session); } } catch (Facebook.FacebookOAuthException exc) { if (!this.facebookLoginHandled) { // Handle error case MessageBox.Show("Not signed in: " + exc.Message); this.facebookLoginHandled = true; } } return(new Uri("/MainPage.xaml", UriKind.Relative)); } // by default, navigate to the requested uri return(uri); }
private void DismissDialogWhenDone(Uri navigationUri) { if (ParentControlPopup != null) { var task = Task.Run(async() => await AppAuthenticationHelper.GetFacebookConfigValue("Facebook", "AppId")); task.Wait(); // cancel the navigation when we successfully hit the send if (navigationUri.ToString().StartsWith(String.Format("fb{0}", task.Result))) { ParentControlPopup.IsOpen = false; } // Parse the Uri string and based on the results, invoke the callback if (OnDialogFinished != null) { // TODO: Fix this and send the correct results back based on the results returned by the dialog OnDialogFinished(WebDialogResult.WebDialogResultDialogCompleted); } } }
public void ShowFeedDialog(string toId = "", string link = "", string linkName = "", string linkCaption = "", string linkDescription = "", string picture = "") { #if WINDOWS || WINDOWS_UNIVERSAL LifecycleHelper.OnDialogDismissed = null; LifecycleHelper.OnDialogDismissed += DismissDialogWhenDone; #endif var task = Task.Run(async() => await AppAuthenticationHelper.GetFacebookConfigValue("Facebook", "AppId")); task.Wait(); #if WINDOWS dialogWebBrowser.Navigate(new Uri(String.Format("https://facebook.com/dialog/feed?display=popup&app_id={0}&redirect_uri=https://www.facebook.com/connect/login_success.html&to={1}&link={2}&name={3}&caption={4}&description={5}&picture={6}", task.Result, toId, link, linkName, linkCaption, linkDescription, picture), UriKind.Absolute)); #endif #if WP8 dialogWebBrowser.Navigate(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/feed?access_token={0}&redirect_uri=fbconnect%3A%2F%2Fsuccess&app_id={1}&display=touch&to={2}&link={3}&name={4}&caption={5}&description={6}&picture={7}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, task.Result, toId, link, linkName, linkCaption, linkDescription, picture))); #endif #if WINDOWS_PHONE dialogWebBrowser.Navigate(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/feed?access_token={0}&redirect_uri=fb{2}%3A%2F%2Fsuccess&app_id={1}&display=touch&to={3}&link={4}&name={5}&caption={6}&description={7}&picture={8}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, task.Result, task.Result, toId, link, linkName, linkCaption, linkDescription, picture))); #endif }
public void ShowFeedDialog() { #if WINDOWS || WINDOWS_UNIVERSAL LifecycleHelper.OnDialogDismissed = null; LifecycleHelper.OnDialogDismissed += DismissDialogWhenDone; #endif var task = Task.Run(async() => await AppAuthenticationHelper.GetFacebookConfigValue("Facebook", "AppId")); task.Wait(); #if WINDOWS dialogWebBrowser.Navigate(new Uri(String.Format("https://facebook.com/dialog/feed?display=popup&app_id={0}&message=YOUR_MESSAGE_HERE!&redirect_uri=https://www.facebook.com/connect/login_success.html", task.Result), UriKind.Absolute)); #endif #if WP8 dialogWebBrowser.Navigate(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/feed?access_token={0}&redirect_uri=fbconnect%3A%2F%2Fsuccess&app_id={1}&display=touch", Session.ActiveSession.CurrentAccessTokenData.AccessToken, task.Result))); #endif #if WINDOWS_PHONE dialogWebBrowser.Navigate(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/feed?access_token={0}&redirect_uri=fb{2}%3A%2F%2Fsuccess&app_id={1}&display=touch", Session.ActiveSession.CurrentAccessTokenData.AccessToken, task.Result, task.Result))); #endif }
public void ShowAppRequestsDialog(WebDialogFinishedDelegate callback) { if (callback != null) { OnDialogFinished += callback; } // Remove all dialog dismiss delegates since only one dialog can be active at one point of time. LifecycleHelper.OnDialogDismissed = null; LifecycleHelper.OnDialogDismissed += DismissDialogWhenDone; var task = Task.Run(async() => await AppAuthenticationHelper.GetFacebookConfigValue("Facebook", "AppId")); task.Wait(); //Uri uri = // new Uri( // String.Format( // "https://m.facebook.com/v2.1/dialog/apprequests?access_token={0}&redirect_uri=fbconnect%3A%2F%2Fsuccess&app_id={1}&message=YOUR_MESSAGE_HERE&display=touch", // Session.ActiveSession.CurrentAccessTokenData.AccessToken, task.Result)); dialogWebBrowser.Navigate(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/apprequests?access_token={0}&redirect_uri=fb{2}%3A%2F%2Fsuccess&app_id={1}&message=YOUR_MESSAGE_HERE&display=touch", Session.ActiveSession.CurrentAccessTokenData.AccessToken, task.Result, task.Result))); }
public void ShowAppRequestsDialog(WebDialogFinishedDelegate callback, string message, string title, List <string> idList) { if (callback != null) { OnDialogFinished += callback; } var task = Task.Run(async() => await AppAuthenticationHelper.GetFacebookConfigValue("Facebook", "AppId")); task.Wait(); #if WINDOWS || WINDOWS_UNIVERSAL LifecycleHelper.OnDialogDismissed = null; LifecycleHelper.OnDialogDismissed += DismissDialogWhenDone; #endif var idBuilder = new StringBuilder("&to="); if (idList != null) { foreach (var id in idList) { idBuilder.Append(id + ","); } } //idBuilder.Length > 4? idBuilder.ToString() : String.Empty; #if WINDOWS dialogWebBrowser.Navigate(new Uri(String.Format("https://facebook.com/dialog/apprequests?display=popup&app_id={0}&message={1}&redirect_uri=https://www.facebook.com/connect/login_success.html{2}&title={3}", task.Result, message, idBuilder.Length > 4? idBuilder.ToString() : String.Empty, title), UriKind.Absolute)); #endif #if WINDOWS_PHONE dialogWebBrowser.Navigate(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/apprequests?access_token={0}&redirect_uri=fb{2}%3A%2F%2Fsuccess&app_id={1}&message={3}&display=touch{4}&title={5}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, task.Result, task.Result, message, idBuilder.Length > 4 ? idBuilder.ToString() : String.Empty, title))); #endif #if WP8 dialogWebBrowser.Navigate(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/apprequests?access_token={0}&redirect_uri=fbconnect%3A%2F%2Fsuccess&app_id={1}&message={2}&display=touch{3}&title={4}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, task.Result, message, idBuilder.Length > 4 ? idBuilder.ToString() : String.Empty, title))); #endif }
async private void DialogWebBrowserOnLoadCompleted(object sender, NavigationEventArgs args) #endif { if (args.Uri.ToString().StartsWith("https://www.facebook.com/connect/login_success.html")) { if (ParentControlPopup != null) { ParentControlPopup.IsOpen = false; } if (!args.Uri.Fragment.Contains("access_token")) { // this callback is in return for the dialog, so just cancel it. if (OnDialogFinished != null) { OnDialogFinished(WebDialogResult.WebDialogResultDialogCompleted); } return; } try { var client = new FacebookClient(); var authResult = client.ParseOAuthCallbackUrl(args.Uri); client = new FacebookClient(authResult.AccessToken); var parameters = new Dictionary <string, object>(); parameters["fields"] = "id"; var result = await client.GetTaskAsync("me", parameters); var dict = (IDictionary <string, object>)result; var task = Task.Run(async() => await AppAuthenticationHelper.GetFacebookConfigValue("Facebook", "AppId")); task.Wait(); Session.ActiveSession.CurrentAccessTokenData = new AccessTokenData { AccessToken = authResult.AccessToken, Expires = authResult.Expires, FacebookId = (string)dict["id"], AppId = task.Result }; if (Session.OnFacebookAuthenticationFinished != null) { Session.OnFacebookAuthenticationFinished(Session.ActiveSession.CurrentAccessTokenData); } if (Session.OnSessionStateChanged != null) { Session.OnSessionStateChanged(LoginStatus.LoggedIn); } } catch (Facebook.FacebookOAuthException exc) { // TODO: (sanjeevd) catch appropriately } } }