Exemplo n.º 1
0
        public void AuthenticateTwitter(object sender, EventArgs e)
        {
            TwitterHelper twthelper = new TwitterHelper();
            string twtredirecturl = twthelper.TwitterRedirect(ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], ConfigurationManager.AppSettings["callbackurl"]);
            Response.Redirect(twtredirecturl);

            oAuthTwitter OAuth = new oAuthTwitter();

            if (Request["oauth_token"] == null)
            {
                OAuth.AccessToken = string.Empty;
                OAuth.AccessTokenSecret = string.Empty;
                OAuth.CallBackUrl = ConfigurationManager.AppSettings["callbackurl"].ToString();
                this.TwitterOAuth.HRef = OAuth.AuthorizationLinkGet();
                Response.Redirect(OAuth.AuthorizationLinkGet());
            }
        }
Exemplo n.º 2
0
        public void AuthenticateTwitter(object sender, EventArgs e)
        {
            oAuthTwitter OAuth = new oAuthTwitter();

            if (Request["oauth_token"] == null)
            {
                OAuth.AccessToken = string.Empty;
                OAuth.AccessTokenSecret = string.Empty;
                OAuth.CallBackUrl = ConfigurationManager.AppSettings["callbackurl"].ToString();
                Response.Redirect(OAuth.AuthorizationLinkGet());
            }
        }
Exemplo n.º 3
0
        public void TwitterRedirect(object sender, EventArgs e)
        {
            if (ddlGroup.SelectedItem.Text != "Select")
            {
                Session["UserAndGroupsForTwitter"] = "twitter";

                oAuthTwitter OAuth = new oAuthTwitter();

                if (Request["oauth_token"] == null)
                {
                    OAuth.AccessToken = string.Empty;
                    OAuth.AccessTokenSecret = string.Empty;
                    OAuth.CallBackUrl = ConfigurationManager.AppSettings["callbackurl"].ToString();
                    Response.Redirect(OAuth.AuthorizationLinkGet());
                }
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "test", "<script type=\"text/javascript\">alert(\"Select the group to add profiles\")</script>", false);

            }
        }
Exemplo n.º 4
0
        public void TwitterOAuthRedirect(object sender, EventArgs e)
        {
            User user = (User)Session["LoggedUser"];

            oAuthTwitter OAuth = new oAuthTwitter();

            if (ddlGroup.SelectedIndex > 0)
            {
                HiddenFieldGroupNameInDDl.Value = ddlGroup.SelectedItem.Text;

                if (!string.IsNullOrEmpty(HiddenFieldGroupNameInDDl.Value))
                {
                    GroupRepository grouprepo = new GroupRepository();
                    Groups group = grouprepo.getGroupDetails(user.Id, HiddenFieldGroupNameInDDl.Value.ToString());
                    Session["GroupName"] = group;
                    TwitterHelper twthelper = new TwitterHelper();
                    string twtredirecturl = twthelper.TwitterRedirect(ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], ConfigurationManager.AppSettings["callbackurl"]);
                    Response.Redirect(twtredirecturl);

                }
            }
            else
            {
                try
                {
                    string txtgroup = Page.Request.Form["txtGroupName"].ToString();

                    if (!string.IsNullOrEmpty(txtgroup))
                    {
                        GroupRepository grouprepo = new GroupRepository();
                        Groups group = new Groups();
                        group.Id = Guid.NewGuid();
                        group.GroupName = txtgroup;
                        group.UserId = user.Id;
                        group.EntryDate = DateTime.Now;
                        if (!grouprepo.checkGroupExists(user.Id, txtgroup))
                        {
                            grouprepo.AddGroup(group);
                            Groups grou = grouprepo.getGroupDetails(user.Id, txtgroup);
                            Session["GroupName"] = grou;
                        }
                        else
                        {
                            Groups grou = grouprepo.getGroupDetails(user.Id, txtgroup);
                            Session["GroupName"] = grou;
                        }
                        if (Request["oauth_token"] == null)
                        {
                            Session["UserAndGroupsForTwitter"] = "twitter";
                            OAuth.AccessToken = string.Empty;
                            OAuth.AccessTokenSecret = string.Empty;
                            OAuth.CallBackUrl = ConfigurationManager.AppSettings["callbackurl"].ToString();
                            this.TwitterOAuth.HRef = OAuth.AuthorizationLinkGet();
                            Response.Redirect(OAuth.AuthorizationLinkGet());
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert(\"Please Add new Group or Select Existing Group\");</script>");
                    }

                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
            }
        }