diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-01-11 09:50:07 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-01-11 20:38:34 -0800 |
commit | ebb410df2ce3cb1884c0f264b0391dcbae290db1 (patch) | |
tree | 8aa6d640ec5a9fcdd5a78688cef022be593776a4 /samples/OAuthConsumer/Twitter.aspx.cs | |
parent | 83ff5ac2e46759ab588a0a8ae165b6544ce36290 (diff) | |
download | DotNetOpenAuth-ebb410df2ce3cb1884c0f264b0391dcbae290db1.zip DotNetOpenAuth-ebb410df2ce3cb1884c0f264b0391dcbae290db1.tar.gz DotNetOpenAuth-ebb410df2ce3cb1884c0f264b0391dcbae290db1.tar.bz2 |
Updated TwitterConsumer sample in the ApplicationBlock to include profile image upload.
Added an Upload Photo button to the Twitter sample page.
Diffstat (limited to 'samples/OAuthConsumer/Twitter.aspx.cs')
-rw-r--r-- | samples/OAuthConsumer/Twitter.aspx.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/samples/OAuthConsumer/Twitter.aspx.cs b/samples/OAuthConsumer/Twitter.aspx.cs index 9b9eced..f309396 100644 --- a/samples/OAuthConsumer/Twitter.aspx.cs +++ b/samples/OAuthConsumer/Twitter.aspx.cs @@ -75,4 +75,20 @@ public partial class Twitter : System.Web.UI.Page { tableBuilder.Append("</table>"); resultsPlaceholder.Controls.Add(new Literal { Text = tableBuilder.ToString() }); } + + protected void uploadProfilePhotoButton_Click(object sender, EventArgs e) { + if (profilePhoto.PostedFile.ContentType == null) { + photoUploadedLabel.Visible = true; + photoUploadedLabel.Text = "Select a file first."; + return; + } + + var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager); + XDocument imageResult = TwitterConsumer.UpdateProfileImage( + twitter, + this.AccessToken, + profilePhoto.PostedFile.InputStream, + profilePhoto.PostedFile.ContentType); + photoUploadedLabel.Visible = true; + } } |