Esempio n. 1
0
        static void TestAsyncGSRequest()
        {
            string method = "socialize.getUserInfo";

            // Should give response from server
            GSRequest request = new GSRequest(apiKey, secretKey, method, false);

            request.SetParam("uid", "3111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111");
            request.SetParam("enabledProviders", "*,testnetwork,testnetwork2");
            request.APIDomain = "";

            GSResponse   response = null;
            IAsyncResult iar      = request.BeginSend((IAsyncResult innerIAsyncResult) =>
            {
                response = request.EndSend(innerIAsyncResult);
            }, 123);

            iar.AsyncWaitHandle.WaitOne();

            System.Console.WriteLine("Response: " + response.GetResponseText());
            // Should fail before getting to server

            //request = new GSRequest(apiKey, secretKey+"123", method, false);
            //request.SetParam("uid", "di1");
            //request.SetParam("enabledProviders", "*,testnetwork,testnetwork2");

            //response = null;
            //iar = request.BeginSend((IAsyncResult innerIAsyncResult) => {
            //    response = request.EndSend(innerIAsyncResult);
            //}, 123);

            //iar.AsyncWaitHandle.WaitOne();
        }
Esempio n. 2
0
        static void TestGetUserInfo(string[] args)
        {
            // Step 1 - Defining the request
            string    method  = "socialize.getUserInfo";
            GSRequest request = new GSRequest(apiKey, secretKey, method, true);

            // Step 2 - Adding parameters
            request.SetParam("uid", "di1");                   // set the "uid" parameter to user's ID
            request.SetParam("enabledProviders", "*,testnetwork,testnetwork2");
            request.SetParam("status", "I feel great 22222"); // set the "status" parameter to "I feel great"

            // Step 3 - Sending the request
            GSResponse response = request.Send();

            bool validate = SigUtils.ValidateUserSignature(
                response.GetString("UID", ""),
                response.GetString("signatureTimestamp", ""), secretKey,
                response.GetString("UIDSignature", ""));

            // Step 4 - handling the request's response.
            if (response.GetErrorCode() == 0)
            {    // SUCCESS! response status = OK
                Console.WriteLine("Success in setStatus operation.");
            }
            else
            {  // Error
                Console.WriteLine("Got error on setStatus: {0}", response.GetErrorMessage());
            }
        }
Esempio n. 3
0
 public ActionResult Sdk(string network, string method)
 {
     var request = new GSRequest(GetAccessToken(network), method);
     GSResponse response = request.Send();
     var result = string.Concat("<pre><code>", response.GetResponseText(), "</code></pre>");
     return Json(result, JsonRequestBehavior.AllowGet);
 }
Esempio n. 4
0
        private GSRequest getGigyaRequest(string method)
        {
            // Define the API-Key and Secret key (the keys can be obtained from your site setup page on Gigya's website).

            GSRequest request = new GSRequest(apiKey, secretKey, method, false);

            request.APIDomain = "eu1.gigya.com";
            return(request);
        }
Esempio n. 5
0
        public ActionResult AccountsGetAccountInfo(string network, string uid)
        {
            var request = new GSRequest(GetAccessToken(network), "accounts.getAccountInfo");
            request.SetParam("UID", uid);

            GSResponse response = request.Send();
            var result = string.Concat("<pre><code>", response.GetResponseText(), "</code></pre>");
            return Json(result, JsonRequestBehavior.AllowGet);
        }
Esempio n. 6
0
        public GSResponse Send(string uid, string apiKey, string secretKey, string apiMethod, string json, bool useHTTPS, string apiDomain, out string format)
        {
            GSObject dict = new GSObject(json);

            dict.Put("uid", uid);
            format = dict.GetString("format", "json");
            GSRequest req = new GSRequest(apiKey, secretKey, apiMethod, dict, useHTTPS);

            req.APIDomain = "";
            return(req.Send());
        }
        protected virtual GSRequest NewRequest(GigyaModuleSettings settings, string applicationSecret, string method)
        {
            var request = new GSRequest(settings.ApiKey, applicationSecret, method, null, true, settings.ApplicationKey);

            if (!string.IsNullOrEmpty(settings.DataCenter))
            {
                request.APIDomain = settings.DataCenter;
            }

            return(request);
        }
Esempio n. 8
0
 public void RequestForMethodWithParamethers()
 {
     try
     {
         var r = GSRequest.RequestForMethod("method", new NSDictionary());
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
     Assert.Pass();
 }
Esempio n. 9
0
 public void RequestForMethod()
 {
     try
     {
         var r = GSRequest.RequestForMethod("method");
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
     Assert.Pass();
 }
Esempio n. 10
0
        public ActionResult SocializeFacebookGraphOperation(string graphPath, string graphParams, string method = "get")
        {
            var request = new GSRequest(GetAccessToken("facebook"), "socialize.facebookGraphOperation");
            request.SetParam("graphPath", graphPath);
            request.SetParam("method", method);

            if (!string.IsNullOrWhiteSpace(graphParams))
                request.SetParam("graphParams", graphParams);

            GSResponse response = request.Send();
            var result = string.Concat("<pre><code>", response.GetResponseText(), "</code></pre>");
            return Json(result, JsonRequestBehavior.AllowGet);
        }
Esempio n. 11
0
        void GetUserInfo()
        {
            var request = GSRequest.RequestForMethod("socialize.getUserInfo");

            request.SendWithResponseHandler((responce, error) =>
            {
                if (error == null)
                {
                }
                else
                {
                }
            });
        }
Esempio n. 12
0
        public async Task <bool> Login(string password)
        {
            // Step 1 - Defining the request
            GSRequest request = getGigyaRequest("accounts.login");



            // Step 2 - Adding parameters
            request.SetParam("loginID", Email);     // set the "uid" parameter to user's ID
            request.SetParam("password", password); // set the "status" parameter to "I feel great"

            // Step 3 - Sending the request
            GSResponse response = await Task <GSResponse> .Factory.FromAsync(request.BeginSend, request.EndSend, TaskCreationOptions.None);

            return(response.GetErrorCode() == 0);
        }
Esempio n. 13
0
        private static void GetUserInfoTester()
        {
            GetUserInfoRequestParams reqParams = new GetUserInfoRequestParams
            {
                uid = "31x31",
                enabledProviders = "*,testnetwork,testnetwork2"
            };


            // Typed Class
            GSRequest  req = new GSRequest(apiKey, secretKey, "socialize.getUserInfo", reqParams, false);
            GSResponse res = req.Send();

            GigyaResponse response = res.GetData <GigyaResponse>();

            Debug.Assert(response.errorCode > 0, "failed to cast to GigyaResponse #1");

            // GS Object
            req = new GSRequest(apiKey, secretKey, "socialize.getUserInfo", new GSObject(reqParams), false);
            res = req.Send();

            response = res.GetData <GigyaResponse>();
            Debug.Assert(response.errorCode > 0, "failed to cast to GigyaResponse #2");

            // Anonymous type
            req = new GSRequest(apiKey, secretKey, "socialize.getUserInfo", new
            {
                format = "json",
                uid    = "31x31",
                arr    = new List <string> {
                    "1", "2", "3"
                },
                myClass     = new MyClass(),
                myClassList = new List <MyClass> {
                    new MyClass()
                },
                enabledProviders = "*,testnetwork,testnetwork2"
            }, false);

            res = req.Send();

            // Cast to GigyaResponse
            response = res.GetData <GigyaResponse>();
            Debug.Assert(response.errorCode > 0, "failed to cast to GigyaResponse #3");
        }
Esempio n. 14
0
        private async void FetchFriendsList()
        {
            // Create the request
            var friendsRequest = GSRequest.Create("socialize.getFriendsInfo");

            friendsRequest.Parameters["detailLevel"] = (NSString)"extended";

            try
            {
                // Send it and handle the response
                var response = await friendsRequest.SendAsync();

                friends = (JArray)JObject.Parse(response.JsonString)["friends"];

                TableView.ReloadData();
                activityIndicator.StopAnimating();
            }
            catch (NSErrorException ex)
            {
                // If the operation is still pending, wait for 5 seconds and try again
                // See: http://developers.gigya.com/display/GD/socialize.getFriendsInfo+REST
                if (ex.Error.Code == 100001)
                {
                    await Task.Delay(5000);

                    FetchFriendsList();
                }
                else
                {
                    Console.WriteLine("Error loading friends: {0}", ex.Error);
                    activityIndicator.StopAnimating();

                    if (ex.Error.Code == 403005 || ex.Error.Code == 403007)
                    {
                        await TabBarController.PresentingViewController.DismissViewControllerAsync(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error loading friends: {0}", ex.Message);
                activityIndicator.StopAnimating();
            }
        }
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            // If there is a user, update the display. Otherwise fetch the user info
            if (User != null)
            {
                UpdateUserInfo();
            }
            else
            {
                var request = GSRequest.Create("socialize.getUserInfo");

                // GSUser inherits from GSResponse. socialize.getUserInfo will always return GSUser if completed successfully
                User = (GSUser)await request.SendAsync();

                UpdateUserInfo();
            }
        }
Esempio n. 16
0
        void SetStatus()
        {
            Console.WriteLine(new GSSession().Token);

            var request = GSRequest.RequestForMethod("socialize.setStatus");

            request.Parameters.SetValueForKey(new NSString("Posted via Gigya test app"), new NSString("status"));
            request.SendWithResponseHandler((responce, error) =>
            {
                if (error == null)
                {
                    // Request was successful
                }
                else
                {
                    // Handle error
                }
            });
        }
Esempio n. 17
0
            private string getEncodedValues(string paramsString)
            {
                string ret = "";

                // Split by &
                string[] keyValuePairs = paramsString.Split(new char[] { '&' });
                // For every pair
                for (int i = 0; i < keyValuePairs.Length; i++)
                {
                    int indexOf = keyValuePairs[i].IndexOf("=");
                    if (indexOf == -1)
                    {
                        continue;
                    }
                    string key   = keyValuePairs[i].Substring(0, indexOf);
                    string value = keyValuePairs[i].Substring(indexOf + 1);
                    ret += key + "=" + GSRequest.UrlEncode(value) + "&";
                }
                ret = ret.Remove(ret.Length - 1);
                return(ret);
            }
Esempio n. 18
0
        /// <summary>
        /// Call to accounts.getJWT to generate an id_token - a JWT to validate after
        /// </summary>
        public string GetJWT()
        {
            var clientParams = new GSObject();

            clientParams.Put("fields", "profile.firstName,profile.lastName,email,data.userKey");
            clientParams.Put("targetUID", targetUID);

            var req = new GSRequest(
                apiKey,
                secret,
                "accounts.getJWT",
                clientParams)
            {
                APIDomain = apiDomain
            };

            var res = req.Send();

            Assert.IsTrue(res.GetErrorCode() == 0, "res.GetErrorCode() != 0");

            return(res.GetData().GetString("id_token"));
        }
        public static LinkedList <GSRequest> Read(GSInstance gsInstance)
        {
            Log(gsInstance, "Reading Persistent Queue");

            LinkedList <GSRequest> persistantQueue = new LinkedList <GSRequest> ();
            String      path = GetPath(gsInstance);
            QueueReader qr   = new QueueReader();

            qr.Initialize(path);

            string content = qr.ReadFully();

            qr.Dispose();

            if (content != null)
            {
                using (StringReader reader = new StringReader(content))
                {
                    string line = null;

                    do
                    {
                        line = reader.ReadLine();
                        if (line != null && line.Trim().Length > 0)
                        {
                            GSRequest request = StringToRequest(gsInstance, line);

                            if (request != null)
                            {
                                Log(gsInstance, "read " + request.JSON);
                                persistantQueue.AddLast(request);
                            }
                        }
                    }while (line != null);
                }
            }

            return(persistantQueue);
        }
Esempio n. 20
0
        public async Task <bool> Register(string password)
        {
            // Step 1 - Defining the request

            GSRequest initRequest = getGigyaRequest("accounts.initRegistration");

            GSResponse initResponse = await Task <GSResponse> .Factory.FromAsync(initRequest.BeginSend, initRequest.EndSend, TaskCreationOptions.None);

            if (initResponse.GetErrorCode() != 0)
            {
                return(false);
            }

            string regToken = initResponse.GetString("regToken", null);

            GSRequest regRequest = getGigyaRequest("accounts.register");

            // Step 2 - Adding parameters
            //regRequest.SetParam("username", Email);
            regRequest.SetParam("email", Email); // set the "uid" parameter to user's ID
            regRequest.SetParam("password", password);
            regRequest.SetParam("regToken", regToken);
            regRequest.SetParam("finalizeRegistration", true);

            // Step 3 - Sending the request
            GSResponse regresponse = await Task <GSResponse> .Factory.FromAsync(regRequest.BeginSend, regRequest.EndSend, TaskCreationOptions.None);


            // Step 4 - handling the request's response.
            if (regresponse.GetErrorCode() == 0)
            { // SUCCESS! response status = OK
                return(true);
            }
            else
            { // Error
                return(false);
            }
        }
        private GSResponse Send(GSRequest request, string apiMethod, GigyaModuleSettings settings)
        {
            GSResponse response = null;

            try
            {
                response = request.Send();
            }
            catch (Exception e)
            {
                return(LogError(response, apiMethod, e));
            }

            GigyaApiHelper.LogResponseIfRequired(_logger, settings, apiMethod, response);

            if (response.GetErrorCode() != 0)
            {
                LogError(response, apiMethod, null);
                return(null);
            }

            return(response);
        }
Esempio n. 22
0
        public AccountResponse StartANewAccount(AccountRequest accountRequest)
        {
            string uid = accountRequest.GigyaUID;

            string methodName = "socialize.getUserInfo";

            string apiKey = ConfigurationManager.AppSettings["apikey"];
            string secretKey = ConfigurationManager.AppSettings["secretkey"];

            GSRequest request = new GSRequest(apiKey, secretKey, methodName, false);
            // Step 2 - Adding parameters
            request.setParam("uid", uid);  // set the "uid" parameter to user's ID
            // Step 3 - Sending the request
            GSResponse response = request.send();
            string nickname = response.getString("nickname", "");

            string City = response.getString("city", "");
            string CountryName = response.getString("country", "");
            string FirstName = response.getString("firstName", "");
            string LastName = response.getString("lastName", "");
            string GigyaLoginProvider = response.getString("loginProvider", "");
            string NickName = response.getString("nickname", "");

            Guid? account_id=null;
            using (JourneyDbDataContext journeyDbContext = new JourneyDbDataContext())
            {
                journeyDbContext.AddAccount(accountRequest.GigyaUID, accountRequest.EmailId, accountRequest.Password, accountRequest.DeviceId, accountRequest.CountryCode, GigyaLoginProvider, NickName, FirstName, LastName, City, CountryName, ref account_id);

            }

            AccountResponse ar = new AccountResponse();
            if (account_id.HasValue)
                ar.AccountId = account_id.Value;
            ar.Configuration = new AccountConfiguration();
            return ar;
        }
Esempio n. 23
0
        /// <summary>
        /// Sends a request to the Gigya API.
        /// </summary>
        /// <param name="request">Request object.</param>
        /// <param name="apiMethod">The Gigya method to call.</param>
        /// <param name="settings">The Gigya module settings.</param>
        /// <param name="validateSignature">If set to true, the signature will be validated.</param>
        /// <returns></returns>
        private GSResponse Send(GSRequest request, string apiMethod, IGigyaModuleSettings settings, bool validateSignature)
        {
            if (apiMethod == "accounts.getAccountInfo")
            {
                var environment = new
                {
                    cms_name      = _settingsHelper.CmsName,
                    cms_version   = _settingsHelper.CmsVersion,
                    gigya_version = _settingsHelper.ModuleVersion
                };

                request.SetParam("environment", JsonConvert.SerializeObject(environment));
            }

            if (!string.IsNullOrEmpty(settings.DataCenter))
            {
                request.APIDomain = settings.DataCenter;
            }

            LogRequestIfRequired(settings, apiMethod);

            GSResponse response = null;

            try
            {
                response = request.Send();
            }
            catch (Exception e)
            {
                dynamic gigyaModel = response != null?JsonConvert.DeserializeObject <ExpandoObject>(response.GetResponseText()) : new ExpandoObject();

                var gigyaError = response != null?response.GetErrorMessage() : string.Empty;

                var gigyaErrorDetail = DynamicUtils.GetValue <string>(gigyaModel, "errorDetails");
                var gigyaCallId      = DynamicUtils.GetValue <string>(gigyaModel, "callId");

                _logger.Error(string.Format("API call: {0}. CallId: {1}. Error: {2}. Error Details: {3}.", apiMethod, gigyaCallId, gigyaError, gigyaErrorDetail), e);
                return(response);
            }

            LogResponseIfRequired(settings, apiMethod, response);

            if (response.GetErrorCode() != 0)
            {
                return(response);
            }

            var userId = response.GetString(Constants.GigyaFields.UserId, null);

            if (string.IsNullOrEmpty(userId))
            {
                return(response);
            }

            // no need to validate server calls unless explicitly required e.g. for signature exchange
            if (validateSignature && !ValidateSignature(userId, settings, response))
            {
                if (settings.DebugMode)
                {
                    dynamic gigyaModel = response != null?JsonConvert.DeserializeObject <ExpandoObject>(response.GetResponseText()) : new ExpandoObject();

                    var gigyaCallId = DynamicUtils.GetValue <string>(gigyaModel, "callId");

                    _logger.DebugFormat("Invalid user signature for login request. API call: {0}. CallId: {1}.", apiMethod, gigyaCallId);
                }
                return(null);
            }

            return(response);
        }
Esempio n. 24
0
        public ActionResult SocializeGetRawData(string provider, string fields)
        {
            var request = new GSRequest(GetAccessToken(provider), "socialize.getRawData");
            request.SetParam("provider", provider);
            request.SetParam("fields", fields);
            //request.SetParam("UID", "*****@*****.**");

            GSResponse response = request.Send();
            var result = string.Concat("<pre><code>", response.GetResponseText(), "</code></pre>");
            return Json(result, JsonRequestBehavior.AllowGet);
        }
Esempio n. 25
0
        //private Entitlement getUserProductEntitlement(IPTV2Entities context, System.Guid userId, int productId)
        //{
        //    var user = context.Users.Find(userId);
        //    if (user == null)
        //    {
        //        throw new Exception(String.Format("Invalid user ID {0}", userId));
        //    }

        //    var product = context.Products.Find(productId);
        //    if (product == null)
        //    {
        //        throw new Exception(String.Format("Invalid product ID {0}", productId));
        //    }

        //    // look for user's entitlement of purchased product
        //    Entitlement userEntitlement = null;
        //    if (product is PackageSubscriptionProduct)
        //    {
        //        var pProduct = (PackageSubscriptionProduct)product;
        //        foreach (var p in pProduct.Packages)
        //        {
        //            userEntitlement = user.PackageEntitlements.FirstOrDefault(pp => pp.PackageId == p.PackageId);
        //        }
        //    }
        //    else if (product is ShowSubscriptionProduct)
        //    {
        //        var sProduct = (ShowSubscriptionProduct)product;
        //        foreach (var s in sProduct.Categories)
        //        {
        //            userEntitlement = user.ShowEntitlements.FirstOrDefault(ss => ss.CategoryId == s.CategoryId);
        //        }

        //    }
        //    else if (product is EpisodeSubscriptionProduct)
        //    {
        //        var eProduct = (EpisodeSubscriptionProduct)product;
        //        foreach (var e in eProduct.Episodes)
        //        {
        //            userEntitlement = user.EpisodeEntitlements.FirstOrDefault(ee => ee.EpisodeId == e.EpisodeId);
        //        }

        //    }
        //    else
        //    {
        //        throw new Exception(String.Format("Invalid product type for product Id {0}-{1}.", product.ProductId, product.Name));
        //    }

        //    return (userEntitlement);
        //}

        private void LogToGigya(string type, GomsLogs data)
        {
            try
            {
                string method = "gcs.setObjectData";
                LogModel model = new LogModel() { type = type, data = data };
                string obj = JsonConvert.SerializeObject(model);
                GSRequest req = new GSRequest(GSapikey, GSsecretkey, method, new GSObject(obj), true);
                GSResponse resp = req.Send();
            }
            catch (Exception) { }
        }
Esempio n. 26
0
        public ActionResult SocializeGetSessionInfo(string provider)
        {
            var request = new GSRequest(GetAccessToken(provider), "socialize.getSessionInfo");
            request.SetParam("provider", provider);

            GSResponse response = request.Send();
            var result = string.Concat("<pre><code>", response.GetResponseText(), "</code></pre>");
            return Json(result, JsonRequestBehavior.AllowGet);
        }
Esempio n. 27
0
            private void RunAsync(bool secure, Action <TestRunResult> cb, Action <TestRunResult> onDone)
            {
                try {
                    var ret = new TestRunResult();
                    ret.RunStarted = DateTime.Now;
                    ret.Results    = new List <MethodResult>();


                    var methods = this.Methods;
                    if (!this.RunAll)
                    {
                        methods = this.Methods.Where(m => m.Include).ToList();
                    }

                    foreach (var method in methods)
                    {
                        try {
                            if (method.Params == null)
                            {
                                method.Params = string.Empty;
                            }

                            var methodRes = new MethodResult();
                            methodRes.RunStarted      = DateTime.Now;
                            methodRes.TestName        = method.TestName;
                            methodRes.TestDescription = method.TestDescription;

                            var dict = new GSObject();
                            if (Program.MainForm.chkPreEncodeParams.Checked)
                            {
                                dict.ParseQuerystring(this.getEncodedValues(method.Params.Trim()));
                            }
                            else
                            {
                                dict.ParseQuerystring(method.Params.Trim());
                            }

                            dict.Put("uid", dict.GetString("uid", null));

                            if (GetSecure().HasValue)
                            {
                                secure = GetSecure().Value;
                            }

                            GSRequest g = new GSRequest(this.APIKey, this.SecKey, method.Name, dict, secure);

                            var req = new GSRequest(this.APIKey, this.SecKey, method.Name, dict, secure);
                            var res = req.Send();

                            ret.Results.Add(methodRes);
                            methodRes.Request          = req;
                            methodRes.Response         = res;
                            methodRes.SchemaValidation = new SchemaValidation("http://socialize.api.gigya.com/schema");

                            if (dict.GetString("format").Equals("xml", StringComparison.InvariantCultureIgnoreCase))
                            {
                                var xc = new XmlComparer();
                                xc.Compare(method.Expected, res.GetResponseText(), method.Schema);
                                methodRes.Differences = xc.Differences;

                                var xdoc    = XDocument.Parse(res.GetResponseText());
                                var xroot   = (xdoc.Document.FirstNode as XContainer);
                                var errCode = xroot.Element(XName.Get("errorCode", "urn:com:gigya:api"));


                                int iErrCode;
                                if (errCode != null && int.TryParse(errCode.Value, out iErrCode))
                                {
                                    methodRes.ErrorCode = iErrCode;

                                    var errMsg = xroot.Element(XName.Get("errorMessage", "urn:com:gigya:api"));
                                    methodRes.ErrorMessage = errMsg == null ? string.Empty : errMsg.Value;
                                }

                                else
                                {
                                    methodRes.ErrorCode    = 0;
                                    methodRes.ErrorMessage = "";
                                }


                                if (methodRes.Differences.Count > 0 && methodRes.ErrorCode == 0)
                                {
                                    methodRes.ErrorCode = -1;
                                }

                                var statusCode = xroot.Element(XName.Get("statusCode", "urn:com:gigya:api"));
                                int iStatusCode;

                                if (statusCode != null && int.TryParse(statusCode.Value, out iStatusCode))
                                {
                                    methodRes.StatusCode = iStatusCode;
                                }
                                else
                                {
                                    methodRes.StatusCode = 200;
                                }

                                var sr = new StringReader(res.GetResponseText());
                                methodRes.Validation = methodRes.SchemaValidation.Validate(sr);
                            }
                            else
                            {
                                var jc = new JsonComparer();
                                jc.Compare(method.Expected, res.GetResponseText(), method.Schema);
                                methodRes.Differences = jc.Differences;

                                if (methodRes.Differences.Count > 0 && res.GetErrorCode() == 0)
                                {
                                    methodRes.ErrorCode = -1;
                                }
                                else
                                {
                                    methodRes.ErrorCode = res.GetErrorCode();
                                }

                                methodRes.ErrorMessage = res.GetErrorMessage();
                                methodRes.StatusCode   = res.GetData().GetInt("statusCode", 200);
                                methodRes.Validation   = true;
                            }

                            methodRes.RunEnded = DateTime.Now;


                            //invoke the callback under the UI thread.
                            Program.MainForm.Invoke(cb, ret);
                        }
                        catch (Exception ex) {
                            MessageBox.Show(ex.Message, ex.Message);
                        }
                    }



                    //invoke the callback under the UI thread.
                    Program.MainForm.Invoke(cb, ret);

                    //invoke the callback under the UI thread.
                    Program.MainForm.Invoke(onDone, ret);


                    ret.RunEnded = DateTime.Now;
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message, ex.Message);
                }
            }
Esempio n. 28
0
        public ActionResult SocializeGetUserInfo(string network, string extraFields)
        {
            var request = new GSRequest(GetAccessToken(network), "socialize.getUserInfo");

            if(!string.IsNullOrWhiteSpace(extraFields))
                request.SetParam("extraFields", extraFields);

            GSResponse response = request.Send();
            var result = string.Concat("<pre><code>", response.GetResponseText(), "</code></pre>");
            return Json(result, JsonRequestBehavior.AllowGet);
        }
Esempio n. 29
0
        public ActionResult SocializeNotifyLogin(string network)
        {
            var request = new GSRequest(GetAccessToken(network), "socialize.notifyLogin");
            request.SetParam("siteUID", "*****@*****.**");
            request.SetParam("UIDSig", SigUtils.CalcSignature("*****@*****.**", _appSecret));
            request.SetParam("UIDTimestamp", UnixTimeStamp());
            GSResponse response = request.Send();

            var result = string.Concat("<pre><code>", response.GetResponseText(), "</code></pre>");

            return Json(result, JsonRequestBehavior.AllowGet);
        }
Esempio n. 30
0
        public ActionResult SocializeNotifyRegistration(string network)
        {
            var request = new GSRequest(GetAccessToken(network), "socialize.notifyRegistration");
            request.SetParam("siteUID", "*****@*****.**");
            GSResponse response = request.Send();
            var result = string.Concat("<pre><code>", response.GetResponseText(), "</code></pre>");

            return Json(result, JsonRequestBehavior.AllowGet);
        }
Esempio n. 31
0
 public static GSResponse createAndSendRequest(string method, GSObject obj)
 {
     GSRequest req = new GSRequest(GlobalConfig.GSapikey, GlobalConfig.GSsecretkey, method, obj, true);
     return req.Send();
 }
Esempio n. 32
0
        public JsonResult GetUser(string id)
        {
            UserObj obj = new UserObj() { code = ErrorCode.UnidentifiedError };
            try
            {
                Guid UserId;
                try
                {
                    UserId = Guid.Parse(id);
                }
                catch (Exception) { throw new Exception("UserId is invalid"); }
                var context = new IPTV2Entities();
                var user = context.Users.FirstOrDefault(u => u.UserId == UserId);
                if (user != null)
                {
                    obj.user = new UserO
                    {
                        City = user.City,
                        CountryCode = user.CountryCode,
                        UserId = user.UserId,
                        DateVerified = user.DateVerified.HasValue ? user.DateVerified.Value.ToString("MM/dd/yyyy hh:mm:ss tt") : String.Empty,
                        EMail = user.EMail,
                        FirstName = user.FirstName,
                        IsTVEverywhere = user.IsTVEverywhere
                        ,
                        LastName = user.LastName,
                        RegistrationDate = user.RegistrationDate.ToString("MM/dd/yyyy hh:mm:ss tt"),
                        State = user.State
                    };
                    obj.code = ErrorCode.Success;
                }

                //Gigya
                try
                {
                    Dictionary<string, object> collection = new Dictionary<string, object>();
                    collection.Add("UID", user.UserId.ToString());
                    GSObject gsObj = new GSObject(Newtonsoft.Json.JsonConvert.SerializeObject(collection));
                    GSRequest req = new GSRequest(Global.GSapikey, Global.GSsecretkey, "socialize.getUserInfo", gsObj, true); ;
                    GSResponse res = req.Send();
                    obj.gUser = Newtonsoft.Json.JsonConvert.DeserializeObject<GetUserInfoObj>(res.GetData().ToJsonString());
                }
                catch (Exception) { }
            }
            catch (Exception e) { obj.message = e.Message; }
            return this.Json(obj, JsonRequestBehavior.AllowGet);
        }
Esempio n. 33
0
        public ActionResult SocializeGetFriendsInfo(string network)
        {
            var request = new GSRequest(GetAccessToken(network), "socialize.getFriendsInfo");
            request.SetParam("detailLevel", "extended");

            GSResponse response = request.Send();
            var result = string.Concat("<pre><code>", response.GetResponseText(), "</code></pre>");
            return Json(result, JsonRequestBehavior.AllowGet);
        }