Example #1
0
        public string GetFaceBookEmail()
        {
            string email = "";

            try
            {
                string token = Request.QueryString["FaceBooktoken"];
                if (token != string.Empty && token != null)
                {
                    string         HitURL    = string.Format("https://graph.facebook.com/me?access_token={0}", token);
                    oAuthFacebooks objFbCall = new oAuthFacebooks();
                    string         JSONInfo  = objFbCall.WebRequest(oAuthFacebooks.Method.GET, HitURL, "");

                    var objJson = JsonValue.Parse(JSONInfo);
                    if (objJson.Count > 0)
                    {
                        email = JsonParser.getString(objJson, "email");
                        string firstname = JsonParser.getString(objJson, "first_name");
                        string link      = JsonParser.getString(objJson, "link");
                        string username  = JsonParser.getString(objJson, "username");
                        string gender    = JsonParser.getString(objJson, "gender");
                        string lastname  = JsonParser.getString(objJson, "last_name");
                        FirstName        = firstname;
                        LastName         = lastname;
                        lblAlertMsg.Text = firstname + "Sucessfully Logged In with FaceBook  and the email Address is " + email;
                    }
                }
            }
            catch (Exception exception)
            {
                ProcessException(exception);
            }
            Session.Remove(SessionKeys.ServiceProvider);
            return(email);
        }
Example #2
0
        public void CheckFaceBook()
        {
            string redirect = HttpContext.Current.Request.Url.ToString().Split('?')[0];

            if (Request.QueryString["code"] != null)
            {
                string         code    = Request.QueryString["code"].ToString();
                oAuthFacebooks fbAC    = new oAuthFacebooks(); //Standard FB class file available on net in c#
                string         respnse = "";
                try
                {
                    fbAC.AccessTokenGet(code, redirect);
                    respnse = fbAC.Token;
                }
                catch (Exception exception)
                {
                    ProcessException(exception);
                }
                Response.Redirect(redirect + "?FaceBooktoken=" + respnse);
            }
        }