Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //var twitterCtx = new TwitterContext();

            IOAuthCredentials credentials = new SessionStateCredentials();

            if (credentials.ConsumerKey == null || credentials.ConsumerSecret == null)
            {
                credentials.ConsumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"];
                credentials.ConsumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"];
            }

            auth = new WebAuthorizer
            {
                Credentials = credentials,
                PerformRedirect = authUrl => Response.Redirect(authUrl)
            };

            if (!Page.IsPostBack)
            {
                auth.CompleteAuthorization(Request.Url);
            }

            else if (auth.IsAuthorized)
            {
                Label1.Text = "Congratulations, you're authorized";

            }

            var twitterCtx = new TwitterContext(auth);
            //twitterCtx = auth.IsAuthorized ? new TwitterContext(auth) : new TwitterContext();

            UserId = credentials.UserId;
            string token = credentials.OAuthToken;
            string sec = credentials.AccessToken;

            ////// show token and secret in index page after Authorization
            Label2.Text = token;
            Label3.Text = sec;
            Label4.Text = credentials.UserId;

            ////// creat twtUser object to store the info about the user
            TwitterUser twt = new TwitterUser(UserId, token, sec);

            ////// move user's info to another page throw Session
            Session["objTwt"] = twt;
        }
Пример #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     ///// store user's info from Session
     twt = (TwitterUser)Session["objTwt"];
 }
Пример #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     ///// store user's info from Session
     twt = (TwitterUser)Session["objTwt"];
     MyUsersTableAdapter = new DataSet1TableAdapters.UsersTableAdapter();
 }