internal void ExecuteGraphApiAsync(Method httpMethod, string graphPath, IDictionary<string, string> parameters, bool addAccessToken, Action<FacebookAsyncResult> callback)
        {
            var request = new RestRequest(graphPath, httpMethod);

            if (parameters != null)
            {
                foreach (var keyValuePair in parameters)
                    request.AddParameter(keyValuePair.Key, keyValuePair.Value);
            }

            ExecuteGraphApiAsync(
                request,
                addAccessToken,
                Settings.UserAgent,
                response =>
                {
                    Exception exception;

                    if (response.ResponseStatus == ResponseStatus.Completed)
                        exception = (FacebookException)response.Content;
                    else
                        exception = new FacebookRequestException(response);

                    if (callback != null)
                        callback(new FacebookAsyncResult(response.Content, exception));
                });
        }
        internal void ExecuteGraphApiAsync(Method httpMethod, string graphPath, IDictionary <string, string> parameters, bool addAccessToken, Action <FacebookAsyncResult> callback)
        {
            var request = new RestRequest(graphPath, httpMethod);

            if (parameters != null)
            {
                foreach (var keyValuePair in parameters)
                {
                    request.AddParameter(keyValuePair.Key, keyValuePair.Value);
                }
            }

            ExecuteGraphApiAsync(
                request,
                addAccessToken,
                Settings.UserAgent,
                response =>
            {
                Exception exception;

                if (response.ResponseStatus == ResponseStatus.Completed)
                {
                    exception = (FacebookException)response.Content;
                }
                else
                {
                    exception = new FacebookRequestException(response);
                }

                if (callback != null)
                {
                    callback(new FacebookAsyncResult(response.Content, exception));
                }
            });
        }
Exemple #3
0
        private static string ProcessRestSharpResponse(FacebookGraphRestSharpMessage message, RestResponse response, out Exception exception)
        {
            string result = string.Empty;

            if (response.ResponseStatus == ResponseStatus.Completed)
            {
                exception = (FacebookException)response.Content;

                result = response.Content;
            }
            else
            {
                if (response.ErrorException is System.Security.SecurityException)
                {
                    exception = new ClientAccessPolicyException();
                }
                else
                {
                    // incase the net is not connected or some other exception
                    exception = new FacebookRequestException(response);
                }
            }

            return(result);
        }