public static Login ( string scope = "", FacebookDelegate callback = null ) : void | ||
scope | string | |
callback | FacebookDelegate | |
return | void |
private void checkPermissions(string[] requestedPermissions, Action success, Action <string> fail) { Action checking = () => { List <string> missedPermissions = new List <string>(); foreach (string requestedPermission in requestedPermissions) { if (!this.permissions.Contains(requestedPermission)) { missedPermissions.Add(requestedPermission); } } if (missedPermissions.Count == 0) { success(); return; } string permissionsStr = String.Join(",", missedPermissions.ToArray()); FB.Login(permissionsStr, (FBResult result) => { if (result.Error != null) { SoomlaUtils.LogDebug(TAG, "LoginCallback[result.Error]: " + result.Error); fail(result.Error); return; } if (!FB.IsLoggedIn) { SoomlaUtils.LogDebug(TAG, "LoginCallback[cancelled]"); fail("User has not granter the permissions"); return; } this.permissions.AddRange(missedPermissions); success(); }); }; if (this.permissions == null) { fetchPermissions(checking, fail); } else { checking(); } }
public static void Post(FeedParams FP) { FBScope Scope = new FBScope(); Scope.Scope = ScopeNames.PublishActions; FB.Login(delegate(FBResponse resp) { if (resp.Status == FBStatus.Connected) { FB.API(APINames.Feed, HTTPMethod.POST, FP, delegate(FBResponse response) { }); } }, Scope); }
public static void Authenticate() { if (IsAuthenticated) { //Already Authenticated return; } //Authenticate if not already FB.Login(Permissions, (FBResult result) => { if (result.Error != null) { //Login Error } }); }
private void LoginUser(Action postLogin) { postLoginCallback = postLogin; if (FB.IsLoggedIn) { postLoginCallback(); } else { FB.Login(scope: "", callback: LoginCallback); // FB.Login("email,publish_actions", LoginCallback); } }
private void OnGUI() { float ratio = Screen.width / 600.0f; GUI.skin.label.fontSize = (int)(15 * ratio); GUI.skin.button.fontSize = (int)(15 * ratio); GUI.Label(new Rect(30 * ratio, 30 * ratio, 800 * ratio, 30 * ratio), "Identity: " + myIdentity); if (loading) { return; } if (loggedIn) { if (GUI.Button(new Rect(Screen.width / 2 - 80 * ratio, Screen.height / 2 - 40 * ratio, 160 * ratio, 30 * ratio), "GetCognitoId")) { UpdateIdentity(); } if (GUI.Button(new Rect(Screen.width / 2 - 80 * ratio, Screen.height / 2, 160 * ratio, 30 * ratio), "Clear identity")) { myIdentity = ""; credentials.Clear(); } if (GUI.Button(new Rect(Screen.width / 2 - 80 * ratio, Screen.height / 2 + 40 * ratio, 160 * ratio, 30 * ratio), "Logout")) { Application.LoadLevel(Application.loadedLevel); loggedIn = false; } } else { GUI.skin.button.fontSize = (int)(15 * ratio); if (GUI.Button(new Rect(Screen.width / 2 - 80 * ratio, Screen.height / 2 - 20 * ratio, 160 * ratio, 30 * ratio), "Login with Facebook")) { loading = true; FB.Login("email", FacebookLoginCallback); } if (GUI.Button(new Rect(Screen.width / 2 - 80 * ratio, Screen.height / 2 + 20 * ratio, 160 * ratio, 30 * ratio), "Skip authentication")) { loading = true; InitUnauth(); } } }
//logIn Menù public void fbLogin() { if (FB.IsLoggedIn) { Debug.Log("Already logged in!"); if (Application.loadedLevel == 0) { sendScoreOnFb(); showUILogin(true); } } else { FB.Login("user_friends, email, publish_actions, public_profile", AuthCallback); } }
public void Login(params string[] scopes) { #if FBV6_API_ENABLED string scopesList = string.Empty; foreach (string s in scopes) { if (!scopesList.Equals(string.Empty)) { scopesList += ","; } scopesList += s; } FB.Login(scopesList, LoginCallback); #endif }
public void trySocialLogin(bool allowCache) { Debug.Log("trySocialLogin"); if (FB.IsLoggedIn) { if (allowCache == true) { PushFBDataToFuel(); return; } FB.Logout(); } FB.Login("public_profile,email,publish_actions", LoginCallback); }
// 화면 상의 페이스북 버튼을 누르면 호출되는 함 public void LoginFacebook() { // 페이스북 SDK를 초기화합니다. (페이스북 API 서버 접속) FB.Init(delegate { // FB.ActivateApp() 함수로 페이스북 SDK를 통해 유저가 얼마나 접속하는 지 로깅합니다. 페이스북 관리자 페이지에서 유저의 접속 빈도를 확인할 수 있습니다. FB.ActivateApp(); // 페이스북 SDK로 로그인을 수행합니다. // 유니티 에디터에서는 Access Token을 받아오는 팝업이 뜨지만 // 모바일에서는 잘 연동됩니다. FB.Login("email", delegate(FBResult result) { Debug.Log("FB Login Result: " + result.Text); /* * 저자의 경우 오는 페이스북 로그인 결과 * * {"is_logged_in":true, * "user_id":"10204997009661738", * "access_token":"~~~", * "access_token_expires_at":"01/01/0001 00:00:00"} */ // 페이스북 로그인 결과를 JSON 파싱합니다. JSONObject obj = JSONObject.Parse(result.Text); // 페이스북 로그인이 성공했는지 여부를 뜻하는 is_logged_in 변수 bool형 bool is_logged_in = obj["is_logged_in"].Boolean; // 페이스북 아이디를 UserSingleton에 저장합니다. // 이 변수는 게임이 껏다 켜져도 유지되도록 환경변수에 저장하도록 구현되있습니다. UserSingleton.Instance.FacebookID = obj["user_id"].Str; // 페이스북 액세스 토큰을 UserSingleton에 저장힙니다. // 이 변수 역시 게임이 껏다 켜져도 유지됩니다. UserSingleton.Instance.FacebookAccessToken = obj["access_token"].Str; // 페이스북 로그인에 성공하면 if (is_logged_in) { StartCoroutine(LoadDataFromFacebook()); } else { // 페이스북 로그인에 실패한 경우 } }); }, delegate(bool isUnityShown) { }, ""); }
/// <summary> /// See docs in <see cref="SoomlaProfile.Login"/> /// </summary> /// <param name="success">Callback function that is called if login was successful.</param> /// <param name="fail">Callback function that is called if login failed.</param> /// <param name="cancel">Callback function that is called if login was cancelled.</param> public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel) { FB.Login(this.permissionsStr, (FBResult result) => { if (result.Error != null) { SoomlaUtils.LogDebug(TAG, "LoginCallback[result.Error]: " + result.Error); fail(result.Error); } else if (!FB.IsLoggedIn) { SoomlaUtils.LogDebug(TAG, "LoginCallback[cancelled]"); cancel(); } else { checkPermissions("publish_actions", "user_birthday"); FB.API("/me/permissions", Facebook.HttpMethod.GET, delegate(FBResult response) { // inspect the response and adapt your UI as appropriate // check response.Text and response.Error SoomlaUtils.LogWarning(TAG, "me/permissions " + response.Text); }); FB.API("/me?fields=id,name,email,first_name,last_name,picture", Facebook.HttpMethod.GET, (FBResult result2) => { if (result2.Error != null) { SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Error]: " + result2.Error); fail(result2.Error); } else { SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Text]: " + result2.Text); SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Texture]: " + result2.Texture); string fbUserJson = result2.Text; UserProfile userProfile = UserProfileFromFBJsonString(fbUserJson); SoomlaProfile.StoreUserProfile(userProfile, true); success(userProfile); } }); } }); }
public static void PostToFeed(string pictureURL, string message) { WWWForm form = new WWWForm(); form.AddField("message", message); form.AddField("picture", pictureURL); form.AddField("link", GameConstants.UpgradeBuildURL); if (FB.IsLoggedIn) { FB.API("me/feed", Facebook.HttpMethod.POST, Instance.OnFBSendToFeed, form); } else { Instance.formWithLevelUp = form; FB.Login(mInstance.permissions, Instance.OnFBLoginBeforePostToFeedEvent); } }
private static void AuthenticateAndShare(string name, string caption, string description, string image, string url) { if (IsAuthenticated) { Debug.Log("Facebook is already authenticated!"); return; } FB.Login(Permissions, (FBResult result) => { if (result.Error != null) { Debug.Log("Facebook Login Error: " + result.Error); } else if (IsAuthenticated) { Share(name, caption, description, image, url); } }); }
private static void AuthenticateAndInvite(string inviteTitle, string inviteMessage) { if (IsAuthenticated) { Debug.Log("Facebook is already authenticated!"); return; } FB.Login(Permissions, (FBResult result) => { if (result.Error != null) { Debug.Log("Facebook Login Error: " + result.Error); } else if (IsAuthenticated) { Invite(inviteTitle, inviteMessage); } }); }
private void OnGUI() { if (!loggingIn) { float ratio = Screen.width / 600.0f; GUI.skin.button.fontSize = (int)(15 * ratio); if (GUI.Button(new Rect(Screen.width / 2 - 80 * ratio, Screen.height / 2 - 20 * ratio, 160 * ratio, 30 * ratio), "Login with Facebook")) { loggingIn = true; FB.Login("email", LoginCallback); } if (GUI.Button(new Rect(Screen.width / 2 - 80 * ratio, Screen.height / 2 + 20 * ratio, 160 * ratio, 30 * ratio), "Skip authentication")) { loggingIn = true; GetComponent <SaveManager> ().InitWithoutFacebook(); } } }
private void SetInit() { Console.WriteLine("Init facebook"); enabled = true; // "enabled" is a magic global if (!FB.IsLoggedIn) { FB.Login("email", AuthCallback); } else { if (loggedIN != null) { loggedIN(); } } }
/// <summary> /// See docs in <see cref="SoomlaProfile.Login"/> /// </summary> /// <param name="success">Callback function that is called if login was successful.</param> /// <param name="fail">Callback function that is called if login failed.</param> /// <param name="cancel">Callback function that is called if login was cancelled.</param> public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel) { FB.Login(this.loginPermissionsStr, (FBResult result) => { if (result.Error != null) { SoomlaUtils.LogDebug(TAG, "LoginCallback[result.Error]: " + result.Error); fail(result.Error); } else if (!FB.IsLoggedIn) { SoomlaUtils.LogDebug(TAG, "LoginCallback[cancelled]"); cancel(); } else { this.fetchPermissions(() => { FB.API("/me?fields=id,name,email,first_name,last_name,picture", Facebook.HttpMethod.GET, (FBResult meResult) => { if (meResult.Error != null) { SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Error]: " + meResult.Error); fail(meResult.Error); } else { SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Text]: " + meResult.Text); SoomlaUtils.LogDebug(TAG, "ProfileCallback[result.Texture]: " + meResult.Texture); string fbUserJson = meResult.Text; UserProfile userProfile = UserProfileFromFBJsonString(fbUserJson); userProfile.AccessToken = FB.AccessToken; SoomlaProfile.StoreUserProfile(userProfile, true); success(userProfile); } }); }, (string errorMessage) => { fail(errorMessage); }); } }); }
public static void Feed() { string permissions = "email"; if (!FB.IsInitialized) { FB.Init(Feed); } if (!FB.IsLoggedIn) { FB.Login("publish_action, public_profile, user_friends, email", OnLogin); } else { FeedInternal(); } Debug.Log("Feed"); }
void OnGUI() { GUI.Label(LABELSIZE, panelText, menuSkin.GetStyle("label")); if (!FB.IsLoggedIn) { if (GUI.Button(BUTTONSIZE, "", new GUIStyle())) { FB.Login("email,publish_actions", LoginCallback); } } if (callOnce) { FB.API("/yongqun.yu/picture?width=128&height=128", Facebook.HttpMethod.GET, LogCallback); //FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, APICallback); //FB.API("/yongqun.yu/picture?width=128&height=128", Facebook.HttpMethod.GET, MyPictureCallback); callOnce = false; } GUILayout.BeginArea(new Rect(200, 200, 300, 300)); if (GUILayout.Button("What about click me")) { FB.AppRequest( message: "Friend Smash is smashing! Check it out.", title: "Play Friend Smash with me!" ); } if (GUILayout.Button("What do you want to said")) { FB.Feed( linkCaption: "I just post this Hello World Test Message on facebook for test!!", picture: "http://www.friendsmash.com/images/logo_large.jpg", linkName: "Check out my hello world", link: "https://apps.facebook.com/friendsmashsampledev/?challenge_brag=" ); } if (GUILayout.Button("Play Game")) { Application.LoadLevel("Game1"); } GUILayout.EndArea(); }
void OnGUI() { if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 + 50, 100, 100), "Play")) { if (!Application.isEditor && !FB.IsLoggedIn) { FB.Login("public_profile", OnLogin); } else { if (!NetworkingManager.Connected) { NetworkingManager.Connect(); } Application.LoadLevel("Lobby"); } } }
//Where facebook button is clicked private void onBragClicked() { if (!FB.IsLoggedIn) { // Initialize FB SDK enabled = false; FB.Init(SetInit, OnHideUnity); FB.Login("email,publish_actions", LoginCallback); } FbDebug.Log("onBragClicked"); FB.Feed( linkCaption: "I just scored " + _scoreTotal + " ! Can you beat it?", picture: "http://static.wix.com/media/13f8cb_48245b5b162848f493d15a0f40e05b6b.png?dn=Icone_300.png", linkName: "Checkout my MatchMania greatness! Can you beat me?", link: "http://apps.facebook.com/" + FB.AppId + "/?challenge_brag=" + (FB.IsLoggedIn ? FB.UserId : "guest") ); }
public void ButtonClick() { if (FB.IsLoggedIn) { StartCoroutine("ApplyShare"); } else { FB.Login( "email,publish_actions,user_friends", delegate(FBResult r) { if (FB.IsLoggedIn) { StartCoroutine("ApplyShare"); } } ); } }
void Start() { if (FB.IsLoggedIn) { CheckScore(); } else { FB.Login( "email,publish_actions,user_friends", delegate(FBResult r) { if (FB.IsLoggedIn) { CheckScore(); } } ); } }
/// <summary> /// See docs in <see cref="SoomlaProfile.Login"/> /// </summary> /// <param name="success">Callback function that is called if login was successful.</param> /// <param name="fail">Callback function that is called if login failed.</param> /// <param name="cancel">Callback function that is called if login was cancelled.</param> public override void Login(LoginSuccess success, LoginFailed fail, LoginCancelled cancel) { FB.Login(this.loginPermissionsStr, (FBResult result) => { if (result.Error != null) { SoomlaUtils.LogDebug(TAG, "LoginCallback[result.Error]: " + result.Error); fail(result.Error); } else if (!FB.IsLoggedIn) { SoomlaUtils.LogDebug(TAG, "LoginCallback[cancelled]"); cancel(); } else { success(); } }); }
public void TestFBLogin() { Debug.Log("Entering Testing Facebook Login"); FB.Login("user_profile", (results) => { if (results != null) { Debug.Log("Logging Login Results!"); Debug.Log(results.Json); Debug.Log(results.Text); } else { Debug.Log("Login hit an error!"); } text.text = "Done with Login"; }); }
public void LoginWithFacebook(Action successCallback) { loginSuccessCallback = successCallback; FB.Init(() => { FB.Login("", (x) => { if (FB.IsLoggedIn) { Debug.Log(FB.UserId); loginType = LoginType.Facebook; userID = FB.UserId; LoginToGameServer(); } else { Debug.Log("User cancelled login"); } }); }); }
public IEnumerator StartFacebookLogin2() { WWW www = new WWW(g.internetConnectTestUrl); yield return(www); if (www.isDone && www.error == null) { Debug.Log("CheckInternet www.text=" + www.text); FB.Login("public_profile,email,user_friends,user_games_activity", LoginCallback); } else { Debug.Log("CheckInternet www.error=" + www.error); if (g.isHome) { homeControl.EventInternetWarning(); } } }
public void Share() { if (FB.IsLoggedIn) { FB.Feed( //the message that will appear in the facebook post linkCaption: "I passed the level" + level + " in SPACE TRIP! would you do it better?", //the link of the picture that has to be in the server picture: "https://ksr-ugc.imgix.net/assets/012/722/855/d66f626e8bd456e0ae78effc4302b8b1_original.png?w=1024&h=576&fit=fill&bg=000000&v=1465768833&auto=format&q=92&s=f3ffa21ce542f198b03ad1c42de4810a", //the text that they will see linkName: "Check it out", //that should be the link to google play link: "https://play.google.com/store/apps/details?id=adanzaapps.space.trip2" ); } else { FB.Login("email,publish_actions", AuthCallback); } }
public void AfterInit() { fbactive = true; if (!FB.IsLoggedIn) { try { FB.Login("public_profile,email,user_friends", LoginCallback); } catch (Exception e) { fbactive = false; invitinglab.SetActive(false); } } else { CallAppRequestAsFriendSelector(); } }
public void btnLogin() { if (!isPopup) { Debug.Log("click"); isPopup = true; if (CheckTyc.isOn) { FB.Login("email,user_birthday,user_friends", AuthCallback); } else { NPBinding.UI.ShowAlertDialogWithSingleButton(GMS.appName, "Debes aceptar los términos y condiciones.", "Aceptar", (string _buttonPressed) => { StartCoroutine(changeClick()); //CheckTyc.isOn = true; }); } } //Application.LoadLevel("loader"); }
public void Show(Callback successCallback, Callback failedCallback) { CountRequestConnect = 1; CountRequestReadAllScore = 1; CountSubmitAllScores = 1; CountRequestFriends = 1; CountRequestName = 1; ConnectFacebookStatus = false; ReadScoreStatus = false; SubmitScoreStatus = false; LoadingFriendsStatus = false; if (FB.IsLoggedIn) { return; } usingCallback = true; loadingFriendsStatus = false; readScoreStatus = false; this.successCallback = successCallback; this.failedCallback = failedCallback; if (!FB.IsInitialized) { animator.SetTrigger("Show"); FB.Init(OnInitComplete, OnHideUnity); } else { if (!FB.IsLoggedIn) { animator.SetTrigger("Show"); FB.Login("publish_actions,user_location,user_likes,user_groups,user_friends", LoginCallback); } else { messagePopupController.Show("You have been login!"); } } }