示例#1
0
 public LoginForm(OAuthLinkedIn o)
 {
     _oauth = o;
     _token = null;
     InitializeComponent();
     this.addressTextBox.Text = o.AuthorizationLink;
     _token = _oauth.Token;
     _tokenSecret = _oauth.TokenSecret;
     browser.Navigate(new Uri(_oauth.AuthorizationLink));
 }
示例#2
0
 public LoginForm(OAuthLinkedIn o)
 {
     _oauth = o;
     _token = null;
     InitializeComponent();
     this.addressTextBox.Text = o.AuthorizationLink;
     _token       = _oauth.Token;
     _tokenSecret = _oauth.TokenSecret;
     browser.Navigate(new Uri(_oauth.AuthorizationLink));
 }
        private void button1_Click(object sender, RoutedEventArgs e)
        {

            //Photo p = new Photo();
            //ArrayList a = p.getImage("https://api.500px.com/v1/photos?feature=editors&page=2&consumer_key=HJFMg2LvexMhIKrDs2qaVUxNem27kAxhdfiAYJMW");

            try
            {
                OAuthLinkedIn _oauth = new OAuthLinkedIn();
                String requestToken = _oauth.getRequestToken();
                //txtOutput.Text += "\n" + "Received request token: " + requestToken;
                //succOutput.Text += "Success";
                _oauth.authorizeToken();
                //txtOutput.Text += "\n" + "Token was authorized: " + _oauth.Token + " with verifier: " + _oauth.Verifier;
                //Should be checking the response ;) ;)
         
                String accessToken = _oauth.getAccessToken();
                if (_oauth.Token != "")
                {
                    lblLogin.Content = "You are logged in!";
                    Photo p = new Photo();
                    pictures = p.getImage("https://api.500px.com/v1/photos?feature=editors&page=2&consumer_key=HJFMg2LvexMhIKrDs2qaVUxNem27kAxhdfiAYJMW");
                    MemoryStream ms = new MemoryStream();

                    if (pictures != null)
                    {
                        System.Drawing.Image bm = (System.Drawing.Image)pictures[this.currentImg];
                        bm.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                        System.Windows.Media.Imaging.BitmapImage bImg = new System.Windows.Media.Imaging.BitmapImage();
                        bImg.BeginInit();
                        bImg.StreamSource = new MemoryStream(ms.ToArray());
                        bImg.EndInit();
                        image1.Source = bImg;
                    }
                }
                else
                {
                    lblLogin.Content = "Login Failed!";
                }
                //txtOutput.Text += "\n" + "Access token was received: " + _oauth.Token;
            }
            catch (Exception exp)
            {
                //txtOutput.Text += "\nException: " + exp.Message;
            }
        }