コード例 #1
0
        private static void FormatAuthResponse(ResultContainer result, Utilities.Callback <ResultContainer> callback)
        {
            if (result.ResultDictionary == null)
            {
                callback(result);
                return;
            }

            IDictionary <string, object> authResponse;

            if (result.ResultDictionary.TryGetValue(CanvasFacebook.AuthResponseKey, out authResponse))
            {
                result.ResultDictionary.Remove(CanvasFacebook.AuthResponseKey);
                foreach (var item in authResponse)
                {
                    result.ResultDictionary[item.Key] = item.Value;
                }
            }

            // The JS SDK doesn't always store the permissions so request them before returning the results
            if (result.ResultDictionary.ContainsKey(LoginResult.AccessTokenKey) &&
                !result.ResultDictionary.ContainsKey(LoginResult.PermissionsKey))
            {
                var parameters = new Dictionary <string, string>()
                {
                    { "fields", "permissions" },
                    { Constants.AccessTokenKey, (string)result.ResultDictionary[LoginResult.AccessTokenKey] },
                };
                FacebookDelegate <IGraphResult> apiCallback = (IGraphResult r) =>
                {
                    IDictionary <string, object> permissionsJson;
                    if (r.ResultDictionary != null && r.ResultDictionary.TryGetValue("permissions", out permissionsJson))
                    {
                        IList <string> permissions = new List <string>();
                        IList <object> data;
                        if (permissionsJson.TryGetValue("data", out data))
                        {
                            foreach (var permission in data)
                            {
                                var permissionDictionary = permission as IDictionary <string, object>;
                                if (permissionDictionary != null)
                                {
                                    string status;
                                    if (permissionDictionary.TryGetValue("status", out status) &&
                                        status.Equals("granted", StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        string permissionName;
                                        if (permissionDictionary.TryGetValue("permission", out permissionName))
                                        {
                                            permissions.Add(permissionName);
                                        }
                                        else
                                        {
                                            FacebookLogger.Warn("Didn't find permission name");
                                        }
                                    }
                                    else
                                    {
                                        FacebookLogger.Warn("Didn't find status in permissions result");
                                    }
                                }
                                else
                                {
                                    FacebookLogger.Warn("Failed to case permission dictionary");
                                }
                            }
                        }
                        else
                        {
                            FacebookLogger.Warn("Failed to extract data from permissions");
                        }

                        result.ResultDictionary[LoginResult.PermissionsKey] = permissions.ToCommaSeparateList();
                    }
                    else
                    {
                        FacebookLogger.Warn("Failed to load permissions for access token");
                    }

                    callback(result);
                };
                FB.API(
                    "me",
                    HttpMethod.GET,
                    apiCallback,
                    parameters);
            }
            else
            {
                callback(result);
            }
        }
コード例 #2
0
 public override void ActivateApp(string appId)
 {
     FacebookLogger.Info("This only needs to be called for iOS or Android.");
 }
コード例 #3
0
 public override void ActivateApp(string appId)
 {
     FacebookLogger.Log("Pew! Pretending to send this off.  Doesn't actually work in the editor");
 }
コード例 #4
0
 public override void Init(HideUnityDelegate hideUnityDelegate, InitDelegate onInitComplete)
 {
     FacebookLogger.Warn("You are using the facebook SDK in the Unity Editor. Behavior may not be the same as when used on iOS, Android, or Web.");
     base.Init(hideUnityDelegate, onInitComplete);
     this.editorWrapper.Init();
 }
コード例 #5
0
 public void EnableProfileUpdatesOnAccessTokenChange(bool enable)
 {
     FacebookLogger.Log("Pew! Pretending to enable Profile updates on access token change.  Doesn't actually work in the editor");
 }
コード例 #6
0
 public override void AppEventsLogPurchase(float logPurchase, string currency, Dictionary <string, object> parameters)
 {
     FacebookLogger.Log("Pew! Pretending to send this off.  Doesn't actually work in the editor");
 }
コード例 #7
0
 public override void AppEventsLogEvent(string logEvent, float?valueToSum, Dictionary <string, object> parameters)
 {
     FacebookLogger.Log("Pew! Pretending to send this off.  Doesn't actually work in the editor");
 }
コード例 #8
0
 private void BadAccessToken(string error)
 {
     FacebookLogger.Error(error);
     AccessToken.CurrentAccessToken = null;
     ComponentFactory.GetComponent <EditorFacebookAccessToken>();
 }
コード例 #9
0
        private static void FormatAuthResponse(ResultContainer result, Utilities.Callback <ResultContainer> callback)
        {
            if (result.ResultDictionary == null)
            {
                callback(result);
                return;
            }
            IDictionary <string, object> dictionary;

            if (result.ResultDictionary.TryGetValue("authResponse", out dictionary))
            {
                result.ResultDictionary.Remove("authResponse");
                foreach (KeyValuePair <string, object> current in dictionary)
                {
                    result.ResultDictionary[current.Key] = current.Value;
                }
            }
            if (result.ResultDictionary.ContainsKey(LoginResult.AccessTokenKey) && !result.ResultDictionary.ContainsKey(LoginResult.PermissionsKey))
            {
                Dictionary <string, string> formData = new Dictionary <string, string>
                {
                    {
                        "fields",
                        "permissions"
                    },
                    {
                        "access_token",
                        (string)result.ResultDictionary[LoginResult.AccessTokenKey]
                    }
                };
                FacebookDelegate <IGraphResult> callback2 = delegate(IGraphResult r)
                {
                    IDictionary <string, object> dictionary2;
                    if (r.ResultDictionary != null && r.ResultDictionary.TryGetValue("permissions", out dictionary2))
                    {
                        IList <string> list = new List <string>();
                        IList <object> list2;
                        if (dictionary2.TryGetValue("data", out list2))
                        {
                            foreach (object current2 in list2)
                            {
                                IDictionary <string, object> dictionary3 = current2 as IDictionary <string, object>;
                                if (dictionary3 != null)
                                {
                                    string text;
                                    if (dictionary3.TryGetValue("status", out text) && text.Equals("granted", StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        string item;
                                        if (dictionary3.TryGetValue("permission", out item))
                                        {
                                            list.Add(item);
                                        }
                                        else
                                        {
                                            FacebookLogger.Warn("Didn't find permission name");
                                        }
                                    }
                                    else
                                    {
                                        FacebookLogger.Warn("Didn't find status in permissions result");
                                    }
                                }
                                else
                                {
                                    FacebookLogger.Warn("Failed to case permission dictionary");
                                }
                            }
                        }
                        else
                        {
                            FacebookLogger.Warn("Failed to extract data from permissions");
                        }
                        result.ResultDictionary[LoginResult.PermissionsKey] = list.ToCommaSeparateList();
                    }
                    else
                    {
                        FacebookLogger.Warn("Failed to load permissions for access token");
                    }
                    callback(result);
                };
                FB.API("me", HttpMethod.GET, callback2, formData);
            }
            else
            {
                callback(result);
            }
        }
コード例 #10
0
 public override void GetDeepLink(FacebookDelegate <IGetDeepLinkResult> callback)
 {
     FacebookLogger.Info("No Deep Linking in the Editor");
 }