Ejemplo n.º 1
0
        public static FacebookCreateUserResponse CreateFacebookUser(string facebookAppId, string facebookAppSecret)
        {
            var accessToken = GetFacebookAccessToken(facebookAppId, facebookAppSecret);

            FacebookCreateUserResponse responseObject;
            // Create an user for the app. This returns the OAuth token.
            // https://developers.facebook.com/docs/test_users/
            var facebookCreateNewUserUrl = string.Format(
                @"https://graph.facebook.com/{0}/accounts/test-users?
                installed=true&name=Foo%20Bar&locale=en_US&permissions=read_stream&method=post&{1}",
                facebookAppId,
                accessToken);

            var          createUserRequest = HttpWebRequest.Create(facebookCreateNewUserUrl);
            IAsyncResult asyncResult       = createUserRequest.BeginGetResponse(null, null);

            using (var createUserResponse = createUserRequest.EndGetResponse(asyncResult))
            {
                using (var streamReader = new StreamReader(createUserResponse.GetResponseStream()))
                {
                    var json = ThirdParty.Json.LitJson.JsonMapper.ToObject(streamReader);
                    responseObject = new FacebookCreateUserResponse(json);
                }
            }
            return(responseObject);
        }
Ejemplo n.º 2
0
        public static async Task<FacebookCreateUserResponse> CreateFacebookUser(string facebookAppId, string facebookAppSecret)
        {
            var accessToken = await GetFacebookAccessToken(facebookAppId, facebookAppSecret).ConfigureAwait(false) ;

            FacebookCreateUserResponse responseObject;
            // Create an user for the app. This returns the OAuth token.
            // https://developers.facebook.com/docs/test_users/
            var facebookCreateNewUserUrl = string.Format(
                @"https://graph.facebook.com/{0}/accounts/test-users?
                installed=true&name=Foo%20Bar&locale=en_US&permissions=read_stream&method=post&{1}",
                facebookAppId,
                accessToken);

            var createUserRequest = new HttpRequestMessage();
            createUserRequest.RequestUri = new Uri(facebookCreateNewUserUrl);
            var createUserHttpClient = new HttpClient();
            var createUserResponse =await createUserHttpClient.SendAsync(createUserRequest).ConfigureAwait(false);

            var response = await createUserResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

            var json = ThirdParty.Json.LitJson.JsonMapper.ToObject(response);
            responseObject = new FacebookCreateUserResponse(json);

            return responseObject;
        }
Ejemplo n.º 3
0
 public static void DeleteFacebookUser(FacebookCreateUserResponse user)
 {
     var facebookDeleteUserUrl = string.Format("https://graph.facebook.com/{0}?method=delete&access_token={1}",
     user.ID, user.AccessToken);
     var deleteUserRequest = new UnityWwwRequest(new Uri(facebookDeleteUserUrl));
     deleteUserRequest.GetResponse();
 }
Ejemplo n.º 4
0
        public static FacebookCreateUserResponse CreateFacebookUser(string facebookAppId, string facebookAppSecret)
        {
            var accessToken = GetFacebookAccessToken(facebookAppId, facebookAppSecret);

            FacebookCreateUserResponse responseObject;
            // Create an user for the app. This returns the OAuth token.
            // https://developers.facebook.com/docs/test_users/
            var facebookCreateNewUserUrl = string.Format(
                @"https://graph.facebook.com/{0}/accounts/test-users?
                installed=true&name=Foo%20Bar&locale=en_US&permissions=read_stream&method=post&{1}",
                facebookAppId,
                accessToken);

            var createUserRequest = HttpWebRequest.Create(facebookCreateNewUserUrl);
            IAsyncResult asyncResult = createUserRequest.BeginGetResponse(null, null);
            using (var createUserResponse = createUserRequest.EndGetResponse(asyncResult))
            {
                using (var streamReader = new StreamReader(createUserResponse.GetResponseStream()))
                {
                    var json = ThirdParty.Json.LitJson.JsonMapper.ToObject(streamReader);
                    responseObject = new FacebookCreateUserResponse(json);
                }
            }
            return responseObject;
        }
Ejemplo n.º 5
0
 public static void DeleteFacebookUser(FacebookCreateUserResponse user)
 {
     var facebookDeleteUserUrl = string.Format("https://graph.facebook.com/{0}?method=delete&access_token={1}",
     user.ID, user.AccessToken);
     var deleteUserRequest = HttpWebRequest.Create(facebookDeleteUserUrl);
     using (var deleteUserResponse = deleteUserRequest.GetResponse())
     { }
 }
Ejemplo n.º 6
0
        public static void DeleteFacebookUser(FacebookCreateUserResponse user)
        {
            var facebookDeleteUserUrl = string.Format("https://graph.facebook.com/{0}?method=delete&access_token={1}",
                                                      user.ID, user.AccessToken);
            var deleteUserRequest = new UnityWwwRequest(new Uri(facebookDeleteUserUrl));

            deleteUserRequest.GetResponse();
        }
Ejemplo n.º 7
0
        public static void DeleteFacebookUser(FacebookCreateUserResponse user)
        {
            var facebookDeleteUserUrl = string.Format("https://graph.facebook.com/{0}?method=delete&access_token={1}",
                                                      user.ID, user.AccessToken);
            var          deleteUserRequest = HttpWebRequest.Create(facebookDeleteUserUrl);
            IAsyncResult asyncResult       = deleteUserRequest.BeginGetResponse(null, null);

            deleteUserRequest.EndGetResponse(asyncResult);
        }
Ejemplo n.º 8
0
        public static void DeleteFacebookUser(FacebookCreateUserResponse user)
        {
            var facebookDeleteUserUrl = string.Format("https://graph.facebook.com/{0}?method=delete&access_token={1}",
                                                      user.ID, user.AccessToken);
            var deleteUserRequest = HttpWebRequest.Create(facebookDeleteUserUrl);

            using (var deleteUserResponse = deleteUserRequest.GetResponse())
            { }
        }
Ejemplo n.º 9
0
        public static void DeleteFacebookUser(FacebookCreateUserResponse user)
        {
            var facebookDeleteUserUrl = string.Format("https://graph.facebook.com/{0}?method=delete&access_token={1}",
            user.ID, user.AccessToken);
            var deleteUserRequest = HttpWebRequest.Create(facebookDeleteUserUrl);
            IAsyncResult asyncResult = deleteUserRequest.BeginGetResponse(null, null);
            deleteUserRequest.EndGetResponse(asyncResult);

        }
Ejemplo n.º 10
0
        public static async Task DeleteFacebookUserAsync(FacebookCreateUserResponse user)
        {
            var facebookDeleteUserUrl = string.Format("https://graph.facebook.com/{0}?method=delete&access_token={1}",
            user.ID, user.AccessToken);
            var deleteUserRequest = new HttpRequestMessage();
            deleteUserRequest.RequestUri = new Uri(facebookDeleteUserUrl);
            var deleteUserHttpClient = new HttpClient();
            var deleteUserResponse =await deleteUserHttpClient.SendAsync(deleteUserRequest).ConfigureAwait(false);

            var response = await deleteUserResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
        }