// The Graph API for Scores allows you to publish scores from your game to Facebook // This allows Friend Smash! to create a friends leaderboard keeping track of the top scores achieved by the player and their friends. // For more information on the Scores API see: https://developers.facebook.com/docs/games/scores // // When publishing a player's scores, these scores will be visible to their friends who also play your game. // As a result, the player needs to grant the app an extra permission, publish_actions, in order to publish scores. // This means we need to ask for the extra permission, as well as handling the // scenario where that permission wasn't previously granted. // public static void PostScore(int score, Action callback = null) { // Check for 'publish_actions' as the Scores API requires it for submitting scores if (FBLogin.HavePublishActions) { var query = new Dictionary <string, string>(); query["score"] = score.ToString(); FB.API( "/me/scores", HttpMethod.POST, delegate(IGraphResult result) { Debug.Log("PostScore Result: " + result.RawResult); }, query ); } else { // Showing context before prompting for publish actions // See Facebook Login Best Practices: https://developers.facebook.com/docs/facebook-login/best-practices FBLogin.PromptForPublish(delegate { if (FBLogin.HavePublishActions) { PostScore(score); } }); //PopupScript.SetPopup("Prompting for Publish Permissions for Scores API", 4f, delegate { PROMPTPERMS // // Prompt for `publish actions` and if granted, post score // //}); } }
public void OnLoginClick() { // Disable the Login Button HeaderNotLoggedIn.SetActive(false); // Call Facebook Login for Read permissions of 'public_profile', 'user_friends', and 'email' FBLogin.PromptForLogin(LoginComplete); }
public void OnLoginClick() { Debug.Log("OnLoginClick"); // Disable the Login Button Facebook.interactable = false; FBLogin.PromptForLogin(OnLoginComplete); }
public void OnLoginClick() { Debug.Log("OnLoginClick"); // Disable the Login Button LoginButton.interactable = false; // Call Facebook Login for Read permissions of 'public_profile', 'user_friends', and 'email' FBLogin.PromptForLogin(OnLoginComplete); }
public static void GiveAchievement(string achievementUrl) { if (FBLogin.HavePublishActions) { var data = new Dictionary <string, string>() { { "achievement", achievementUrl } }; FB.API("/me/achievements", HttpMethod.POST, AchievementCallback, data); } else { FBLogin.PromptForPublish(delegate { if (FBLogin.HavePublishActions) { GiveAchievement(achievementUrl); } }); } }
public async Task <HttpResult> FacebookLogin([FromHeader] string authorisation, [FromForm] FBLogin fblogin) { try { if (Functions.CheckAuthorisation(authorisation, out string email, out _)) { var hello = Request; // = (FBLogin)JsonConvert.DeserializeObject(Request.Form.Keys.First()); User loggingIn; bool newUser = false; if (db.User.Any(x => x.Email == email)) { loggingIn = db.User.FirstOrDefault(x => x.Email == email); } else if (!Functions.IsEmail(email)) { throw new Exception("Email invalid!"); } else { newUser = true; BasicRegistrationDetails details = new BasicRegistrationDetails { FirstName = fblogin.FirstName, LastName = fblogin.LastName, Email = email }; loggingIn = await CreateNewUser(details); } loggingIn.SessionToken = Functions.RandomString(40); db.Entry(loggingIn).State = Microsoft.EntityFrameworkCore.EntityState.Modified; Response.Cookies.Append("UserID", loggingIn.Id.ToString()); Response.Cookies.Append("SessionID", loggingIn.SessionToken); db.SaveChanges(); return(new HttpResult(true, new { newUser }, "")); } else { return(new HttpResult(false, null, "Unauthorised!")); } }
void Awake() { instance = this; FB.Init(SetInit, OnHideUnity); }
private void Window_Loaded(object sender, RoutedEventArgs e) { Uri loginUrl = GenerateLoginUrl("628725010617531", "public_profile,user_friends"); FBLogin.Navigate(loginUrl); }