Ejemplo n.º 1
0
    public void SetFacebookData()
    {
        string Email      = "";
        string Name       = "";
        string Id         = "";
        string BDate      = "";
        string gender     = "";
        string profilepic = "";

        if (Request.QueryString["code"] != null)
        {
            FacebookManager objFBMgr    = new FacebookManager();
            string          accesstoken = objFBMgr.GetAccessToken(Request.QueryString["code"], "Default.aspx");
            string          userDetails = objFBMgr.GetUserDetails(accesstoken);
            if (userDetails != "")
            {
                JavaScriptSerializer serializer1     = new JavaScriptSerializer();
                List <UserDetails1>  listUserDetails = serializer1.Deserialize <List <UserDetails1> >("[" + HttpUtility.HtmlDecode(userDetails) + "]");
                Email  = listUserDetails[0].email;
                Name   = listUserDetails[0].name;
                Id     = listUserDetails[0].id;
                BDate  = listUserDetails[0].birthday;
                gender = listUserDetails[0].gender;
                // profilepic=listUserDetails[0].PictureUrl;
                DataSet ds = new DataSet();
                ds = ObjDef.CheckSocialLogin(Id.ToString(), "F");
                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0].ItemArray[0].ToString() == "Y")
                        {
                            Session["CLIENT_ID"]      = ds.Tables[0].Rows[0].ItemArray[1].ToString();
                            Session["CLIENT_CONTACT"] = ds.Tables[0].Rows[0].ItemArray[3].ToString();
                            Session["CLIENT_NAME"]    = ds.Tables[0].Rows[0].ItemArray[2].ToString();
                            Session["CLIENT_EMAIL"]   = ds.Tables[0].Rows[0].ItemArray[4].ToString();
                            //Session["CLIENT_PIC"]=profilepic;
                            string url = "http://www.russsh.com/about-us/Test.aspx?CLIENT_ID=" + ds.Tables[0].Rows[0].ItemArray[1].ToString() + "&CLIENT_CONTACT=" + ds.Tables[0].Rows[0].ItemArray[3].ToString() + "&CLIENT_NAME=" + ds.Tables[0].Rows[0].ItemArray[2].ToString() + "&type=d&pic=" + profilepic;
                            Response.Redirect(url);
                        }
                        else
                        {
                            //txtsname.Value = Name;
                            //txtsemail.Value = Email;
                            Response.Redirect("http://www.russsh.com/about-us/Test.aspx?CLIENT_ID=" + ds.Tables[0].Rows[0].ItemArray[1].ToString() + "&CLIENT_CONTACT=" + ds.Tables[0].Rows[0].ItemArray[3].ToString() + "&CLIENT_NAME=" + Name + "&APPID=" + Id + "&type=Test&source=F&Email=" + Email + "");
                            // Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "onsign();", true);
                        }
                    }
                }
            }
        }
    }