internal static void Get(
     string url,
     Dictionary<string, string> formData = null,
     FacebookDelegate callback = null)
 {
     Request(url, HttpMethod.GET, formData, callback);
 }
Example #2
0
 public static void API(
     string endpoint,
     HttpMethod method,
     FacebookDelegate callback)
 {
     if (method != HttpMethod.GET) throw new NotImplementedException();
     Task.Run(async () =>
     {
         FacebookClient fb = new FacebookClient(_fbSessionClient.CurrentAccessTokenData.AccessToken);
         FBResult fbResult = null;
         try
         {
             var apiCall = await fb.GetTaskAsync(endpoint, null);
             if (apiCall != null)
             {
                 fbResult = new FBResult();
                 fbResult.Text = apiCall.ToString();
                 fbResult.Json = apiCall as JsonObject;
             }
         }
         catch (Exception ex)
         {
             fbResult = new FBResult();
             fbResult.Error = ex.Message;
         }
         if (callback != null)
         {
             Utils.RunOnUnityAppThread(() => { callback(fbResult); });
         }
     });
 }
 internal static void Post(
     string url,
     Dictionary<string, string> formData = null,
     FacebookDelegate<IGraphResult> callback = null)
 {
     Request(url, HttpMethod.POST, formData, callback);
 }
        public override void FeedRequest(
            string _toId = "",
            string _link = "",
            string _linkName = "",
            string _linkCaption = "",
            string _linkDescription = "",
            string _picture = "",
            string _mediaSource = "",
            string _actionName = "",
            string _actionLink = "",
            string _reference = "",
            Dictionary<string, string[]> _properties = null,
            FacebookDelegate callback = null)
        {
            if(!isLoggedIn) return;

            string url = "https://graph.facebook.com/" + _toId +"/feed?method=post";
            if(_link.Length > 0) url += "&link=" +_toId;
            if(_linkName.Length > 0) url += "&name=" +_linkName;
            if(_linkCaption.Length > 0) url += "&caption=" +_linkCaption;
            if(_linkDescription.Length > 0) url += "&description=" +_linkDescription;
            if(_picture.Length > 0) url += "&picture=" +_picture;
            if(_mediaSource.Length > 0) url += "&source=" +_mediaSource;

            if(_actionName.Length > 0 && _actionLink.Length > 0) {
                url += string.Format("&actions=[{\"name\":\"{0}\",\"link\":\"{1}\"}]", _actionName, _actionLink);
            }

            if(_reference.Length > 0) url += "&type" +_reference;

            url += "&access_token=" + accessToken;

            StartCoroutine(GetFBResult(url, callback));
        }
 public void Request(
     Uri url,
     HttpMethod method,
     IDictionary<string, string> formData = null,
     FacebookDelegate<IGraphResult> callback = null)
 {
     AsyncRequestString.Request(url, method, formData, callback);
 }
Example #6
0
 public static void API(
     string endpoint,
     HttpMethod method,
     FacebookDelegate callback)
 {
     if(callback != null)
         callback(new FBResult());
 }
 public void Request(
     Uri url,
     HttpMethod method,
     WWWForm query = null,
     FacebookDelegate<IGraphResult> callback = null)
 {
     AsyncRequestString.Request(url, method, query, callback);
 }
Example #8
0
        public override void Login(string scope = "", FacebookDelegate callback = null)
        {
            if (isLoggedIn)
            {
                FbDebug.Warn("User is already logged in.  You don't need to call this again.");
            }

            userId = "0";
            accessToken = "abcdefghijklmnopqrstuvwxyz";
            isLoggedIn = true;
        }
 internal static void Request(
     string url,
     HttpMethod method,
     Dictionary<string, string> formData = null,
     FacebookDelegate<IGraphResult> callback = null)
 {
     ComponentFactory.AddComponent<AsyncRequestString>()
         .SetUrl(url)
         .SetMethod(method)
         .SetFormData(formData)
         .SetCallback(callback);
 }
Example #10
0
 public override void AppRequest(
     string message,
     string[] to = null,
     string filters = "",
     string[] excludeIds = null,
     int? maxRecipients = null,
     string data = "",
     string title = "",
     FacebookDelegate callback = null)
 {
     fb.AppRequest(message, to, filters, excludeIds, maxRecipients, data, title, callback);
 }
 internal static void Request(
     string url,
     HttpMethod method,
     WWWForm query = null,
     FacebookDelegate<IGraphResult> callback = null)
 {
     ComponentFactory.AddComponent<AsyncRequestString>()
         .SetUrl(url)
         .SetMethod(method)
         .SetQuery(query)
         .SetCallback(callback);
 }
 public override void AppRequest(
     string message,
     string[] to = null,
     string filters = "",
     string[] excludeIds = null,
     int? maxRecipients = null,
     string data = "",
     string title = "",
     FacebookDelegate callback = null)
 {
     throw new UnityException("There is no Facebook AppRequest on Windows Phone 8");
 }
 public override void AppRequest(
     string message,
     OGActionType actionType,
     string objectId,
     string[] to ,
     List<object> filters,
     string[] excludeIds,
     int? maxRecipients ,
     string data,
     string title,
     FacebookDelegate<IAppRequestResult> callback)
 {
     FacebookLogger.Info("App Request dialog is not implemented in the Unity editor.");
 }
Example #14
0
 public override void AppRequest(
     string message,
     OGActionType actionType,
     string objectId,
     string[] to = null,
     List<object> filters = null,
     string[] excludeIds = null,
     int? maxRecipients = null,
     string data = "",
     string title = "",
     FacebookDelegate callback = null)
 {
     FBDebug.Info("App Request dialog is not implemented in the Unity editor.");
 }
Example #15
0
 public override void AppRequest(
     string message,
     OGActionType actionType,
     string objectId,
     string[] to = null,
     List<object> filters = null,
     string[] excludeIds = null,
     int? maxRecipients = null,
     string data = "",
     string title = "",
     FacebookDelegate callback = null)
 {
     fb.AppRequest(message, actionType, objectId, to, filters, excludeIds, maxRecipients, data, title, callback);
 }
Example #16
0
 public override void FeedRequest(
     string toId = "",
     string link = "",
     string linkName = "",
     string linkCaption = "",
     string linkDescription = "",
     string picture = "",
     string mediaSource = "",
     string actionName = "",
     string actionLink = "",
     string reference = "",
     Dictionary<string, string[]> properties = null,
     FacebookDelegate callback = null)
 {
     fb.FeedRequest(toId, link, linkName, linkCaption, linkDescription, picture, mediaSource, actionName, actionLink, reference, properties, callback);
 }
Example #17
0
 public override void FeedRequest(
     string toId = "",
     string link = "",
     string linkName = "",
     string linkCaption = "",
     string linkDescription = "",
     string picture = "",
     string mediaSource = "",
     string actionName = "",
     string actionLink = "",
     string reference = "",
     Dictionary<string, string[]> properties = null,
     FacebookDelegate callback = null)
 {
     FBDebug.Info("Feed dialog is not implemented in the Unity editor.");
 }
        public virtual void API(
            string query,
            HttpMethod method,
            Dictionary<string, string> formData = null,
            FacebookDelegate callback = null)
        {
            Dictionary<string, string> inputFormData;
            // Copy the formData by value so it's not vulnerable to scene changes and object deletions
            inputFormData = (formData != null) ? CopyByValue(formData) : new Dictionary<string, string>();
            if (!inputFormData.ContainsKey(AccessTokenKey) && !query.Contains("access_token="))
            {
              inputFormData[AccessTokenKey] = AccessToken;
            }

            AsyncRequestString.Request(GetGraphUrl(query), method, inputFormData, callback);
        }
Example #19
0
        public override void AppRequest(
            string message,
            string[] to = null,
            string filters = "",
            string[] excludeIds = null,
            int? maxRecipients = null,
            string data = "",
            string title = "",
            FacebookDelegate callback = null)
        {
            Dictionary<string, object> paramsDict = new Dictionary<string, object>();
            // Marshal all the above into the thing

            paramsDict["message"] = message;

            if (callback != null)
            {
                paramsDict["callback_id"] = AddFacebookDelegate(callback);
            }

            if (to != null)
            {
                paramsDict["to"] = string.Join(",", to);
            }

            if (filters != "")
            {
                paramsDict["filters"] = filters;
            }

            if (maxRecipients != null)
            {
                paramsDict["max_recipients"] = maxRecipients.Value;
            }

            if (data != "")
            {
                paramsDict["data"] = data;
            }

            if (title != "")
            {
                paramsDict["title"] = title;
            }

            CallFB("AppRequest", MiniJSON.Json.Serialize(paramsDict));
        }
        public void API(
            string query,
            HttpMethod method,
            Dictionary<string, string> formData,
            FacebookDelegate<IGraphResult> callback)
        {
            Dictionary<string, string> inputFormData;
            // Copy the formData by value so it's not vulnerable to scene changes and object deletions
            inputFormData = (formData != null) ? CopyByValue(formData) : new Dictionary<string, string>();
            if (!inputFormData.ContainsKey(Constants.AccessTokenKey) && !query.Contains("access_token="))
            {
                inputFormData[Constants.AccessTokenKey] =
                    FB.IsLoggedIn ? AccessToken.CurrentAccessToken.TokenString : "";
            }

            AsyncRequestString.Request(GetGraphUrl(query), method, inputFormData, callback);
        }
Example #21
0
        public override void API(
            string query,
            HttpMethod method,
            Dictionary<string, string> formData = null,
            FacebookDelegate callback = null)
        {
            if (query.StartsWith("me"))
            {
                FbDebug.Warn("graph.facebook.com/me does not work within the Unity Editor");
            }

            if (!query.Contains("access_token=") && (formData == null || !formData.ContainsKey("access_token")))
            {
                FbDebug.Warn("Without an access_token param explicitly passed in formData, some API graph calls will 404 error in the Unity Editor.");
            }
            fb.API(query, method, formData, callback);
        }
        public void API(
            string query,
            HttpMethod method,
            WWWForm formData,
            FacebookDelegate<IGraphResult> callback)
        {
            if (formData == null)
            {
                formData = new WWWForm();
            }

            string tokenString = (AccessToken.CurrentAccessToken != null) ?
                AccessToken.CurrentAccessToken.TokenString : "";
            formData.AddField(
                Constants.AccessTokenKey,
                tokenString);

            AsyncRequestString.Request(GetGraphUrl(query), method, formData, callback);
        }
Example #23
0
 public static void PublishInstall(FacebookDelegate callback = null)
 {
     FacebookImpl.PublishInstall(AppId, callback);
 }
Example #24
0
 public static void GetDeepLink(FacebookDelegate callback)
 {
     FacebookImpl.GetDeepLink(callback);
 }
 internal AsyncRequestString SetCallback(FacebookDelegate <IGraphResult> callback)
 {
     this.callback = callback;
     return(this);
 }
 public override void GameGroupJoin(
     string id,
     FacebookDelegate <IGroupJoinResult> callback)
 {
     this.ShowEmptyMockDialog(this.OnGroupJoinComplete, callback, "Mock Group Join");
 }
 public static void PayPremium(
     FacebookDelegate <IPayResult> callback = null)
 {
     Gameroom.GameroomFacebookImpl.PayPremium(callback);
 }
 public abstract void LogInWithReadPermissions(
     IEnumerable <string> scope,
     FacebookDelegate <ILoginResult> callback);
 public override void PublishInstall(string appId, FacebookDelegate callback = null)
 {
 }
 public abstract void GameGroupCreate(
     string name,
     string description,
     string privacy,
     FacebookDelegate <IGroupCreateResult> callback);
 internal static void Request(Uri url, HttpMethod method, [Optional, DefaultParameterValue(null)] IDictionary <string, string> formData, [Optional, DefaultParameterValue(null)] FacebookDelegate <IGraphResult> callback)
 {
     ComponentFactory.AddComponent <AsyncRequestString>().SetUrl(url).SetMethod(method).SetFormData(formData).SetCallback(callback);
 }
 public abstract void GameGroupJoin(
     string id,
     FacebookDelegate <IGroupJoinResult> callback);
Example #33
0
 public void GetUserPhoto(long facebooID, FacebookDelegate <IGraphResult> callBackFunction)
 {
     FB.API(string.Format("/{0}/picture", facebooID), HttpMethod.GET, callBackFunction);
 }
 public override void Login(string scope = "", FacebookDelegate callback = null)
 {
     AddAuthDelegate(callback);
     FBComponentFactory.GetComponent <EditorFacebookAccessToken>();
 }
Example #35
0
 public static void API(string query, HttpMethod method, FacebookDelegate callback, WWWForm formData)
 {
     FacebookImpl.API(query, method, formData, callback);
 }
 /// <summary>
 /// Refreshs the current access to get a new access token if possible.
 /// </summary>
 /// <param name="callback">A on refresh access token compelte callback.</param>
 public static void RefreshCurrentAccessToken(
     FacebookDelegate <IAccessTokenRefreshResult> callback = null)
 {
     Mobile.MobileFacebookImpl.RefreshCurrentAccessToken(callback);
 }
 public abstract void ShareLink(
     Uri contentURL,
     string contentTitle,
     string contentDescription,
     Uri photoURL,
     FacebookDelegate <IShareResult> callback);
 public override void GetAuthResponse(FacebookDelegate callback = null)
 {
     fb.GetAuthResponse(callback);
 }
Example #39
0
 public static void GameGroupJoin(
     string id,
     FacebookDelegate callback = null)
 {
     FacebookImpl.GameGroupJoin(id, callback);
 }
 /// <summary>
 /// Logs the user in with the requested read permissions.
 /// </summary>
 /// <param name="permissions">A list of requested permissions.</param>
 /// <param name="callback">Callback to be called when request completes.</param>
 /// <exception cref="System.NotSupportedException">
 /// Thrown when called on a TV device.
 /// </exception>
 public static void LogInWithReadPermissions(
     IEnumerable <string> permissions         = null,
     FacebookDelegate <ILoginResult> callback = null)
 {
     FacebookImpl.LogInWithReadPermissions(permissions, callback);
 }
Example #41
0
 public void GetFriendList(FacebookDelegate <IGraphResult> callBackFunction)
 {
     FB.API("/me/friends?fields=id,name", HttpMethod.GET, callBackFunction);
 }
 public abstract void GetAppLink(FacebookDelegate <IAppLinkResult> callback);
Example #43
0
        public override void GameGroupCreate(
            string name,
            string description,
            string privacy = "CLOSED",
            FacebookDelegate callback = null)
        {
            Dictionary<string, object> paramsDict = new Dictionary<string, object>();
            paramsDict["name"] = name;
            paramsDict["description"] = description;
            paramsDict["privacy"] = privacy;
            paramsDict["display"] = "async";

            UI(MethodGameGroupCreate, paramsDict, callback);
        }
Example #44
0
 public override void GetDeepLink(FacebookDelegate callback)
 {
     if (callback != null)
     {
         callback(new FBResult(deepLink));
     }
 }
 internal static void Request(Uri url, HttpMethod method, [Optional, DefaultParameterValue(null)] WWWForm query, [Optional, DefaultParameterValue(null)] FacebookDelegate <IGraphResult> callback)
 {
     ComponentFactory.AddComponent <AsyncRequestString>().SetUrl(url).SetMethod(method).SetQuery(query).SetCallback(callback);
 }
Example #46
0
        public override void Pay(
            string product,
            string action = "purchaseitem",
            int quantity = 1,
            int? quantityMin = null,
            int? quantityMax = null,
            string requestId = null,
            string pricepointId = null,
            string testCurrency = null,
            FacebookDelegate callback = null)
        {
            Dictionary<string, object> paramsDict = new Dictionary<string, object>();
            paramsDict["product"] = product;
            paramsDict["action"] = action;
            paramsDict["quantity"] = quantity;

            if (quantityMin.HasValue)
            {
                paramsDict["quantity_min"] = quantityMin.Value;
            }

            if (quantityMax.HasValue)
            {
                paramsDict["quantity_max"] = quantityMax.Value;
            }

            if (!string.IsNullOrEmpty(requestId))
            {
                paramsDict["request_id"] = requestId;
            }

            if (!string.IsNullOrEmpty(pricepointId))
            {
                paramsDict["pricepoint_id"] = pricepointId;
            }

            if (!string.IsNullOrEmpty(testCurrency))
            {
                paramsDict["test_currency"] = testCurrency;
            }

            UI(MethodPay, paramsDict, callback);
        }
 internal static void Post(Uri url, [Optional, DefaultParameterValue(null)] Dictionary <string, string> formData, [Optional, DefaultParameterValue(null)] FacebookDelegate <IGraphResult> callback)
 {
     Request(url, HttpMethod.POST, formData, callback);
 }
Example #48
0
        internal void UI(
                string method,
                Dictionary<string, object> paramsDict,
                FacebookDelegate callback = null)
        {
            if (Screen.fullScreen)
            {
                Screen.fullScreen = false;
            }

            var cloneParamsDict = new Dictionary<string, object>(paramsDict);
            cloneParamsDict["app_id"] = appId;
            var uniqueId = AddFacebookDelegate(callback);
            cloneParamsDict["method"] = method;
            Application.ExternalCall("FBUnity.ui", MiniJSON.Json.Serialize(cloneParamsDict), uniqueId);
        }
Example #49
0
 public override void PublishInstall(string appId, FacebookDelegate callback = null)
 {
     iosFBSettingsPublishInstall(System.Convert.ToInt32(AddFacebookDelegate(callback)), appId);
 }
Example #50
0
 public override void Login(string scope = "", FacebookDelegate callback = null)
 {
     AddAuthDelegate(callback);
     iosLogin(scope);
 }
Example #51
0
 public override void SharePhoto(Texture2D texture2D, Uri photoURL, bool userGenerated, string caption, FacebookDelegate <IShareResult> callback)
 {
     throw new NotImplementedException();
 }
 public static void HasLicense(
     FacebookDelegate <IHasLicenseResult> callback = null)
 {
     Gameroom.GameroomFacebookImpl.HasLicense(callback);
 }
Example #53
0
        public override void GameGroupJoin(
            string id,
            FacebookDelegate callback = null)
        {
            Dictionary<string, object> paramsDict = new Dictionary<string, object>();
            paramsDict["id"] = id;
            paramsDict["display"] = "async";

            UI(MethodGameGroupJoin, paramsDict, callback);
        }
Example #54
0
 public override void ShareVideo(string contentTitle, string contentDescription, Uri preiviewPhotoURL, Uri videoURL, FacebookDelegate <IShareResult> callback)
 {
     throw new NotImplementedException();
 }
Example #55
0
        public override void Login(string scope = "", FacebookDelegate callback = null)
        {
            if (Screen.fullScreen)
            {
                Screen.fullScreen = false;
            }

            AddAuthDelegate(callback);
            Application.ExternalCall("FBUnity.login", scope);
        }
Example #56
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);
            }
        }
Example #57
0
 public override void PublishInstall(string appId, FacebookDelegate callback = null)
 {
     FBDebug.Info("There's no reason to call this on Facebook Canvas.");
 }
 public static void Login(string scope = "", FacebookDelegate callback = null)
 {
     FacebookImpl.Login(scope, callback);
 }
Example #59
0
        public override void AppRequest(
                string message,
                OGActionType actionType,
                string objectId,
                string[] to = null,
                List<object> filters = null,
                string[] excludeIds = null,
                int? maxRecipients = null,
                string data = "",
                string title = "",
                FacebookDelegate callback = null)
        {
            if (string.IsNullOrEmpty(message))
            {
                throw new ArgumentNullException("message", "message cannot be null or empty!");
            }

            if (actionType != null && string.IsNullOrEmpty(objectId))
            {
                throw new ArgumentNullException("objectId", "You cannot provide an actionType without an objectId");
            }

            if (actionType == null && !string.IsNullOrEmpty(objectId))
            {
                throw new ArgumentNullException("actionType", "You cannot provide an objectId without an actionType");
            }

            var paramsDict = new Dictionary<string, object>();
            paramsDict["message"] = message;
            if (to != null)
            {
                paramsDict["to"] = string.Join(",", to);
            }
            if (actionType != null && !string.IsNullOrEmpty(objectId))
            {
                paramsDict["action_type"] = actionType.ToString();
                paramsDict["object_id"] = objectId;
            }
            if (filters != null)
            {
                paramsDict["filters"] = filters;
            }
            if (excludeIds != null)
            {
                paramsDict["exclude_ids"] = excludeIds;
            }
            if (maxRecipients.HasValue)
            {
                paramsDict["max_recipients"] = maxRecipients.Value;
            }
            if (!string.IsNullOrEmpty(data))
            {
                paramsDict["data"] = data;
            }
            if (!string.IsNullOrEmpty(title))
            {
                paramsDict["title"] = title;
            }

            UI(MethodAppRequests, paramsDict, callback);
        }
 public static void API(string query, HttpMethod method, FacebookDelegate callback = null, Dictionary <string, string> formData = null)
 {
     FacebookImpl.API(query, method, formData, callback);
 }