summaryrefslogtreecommitdiffstats
path: root/samples/OAuthConsumer/Twitter.aspx.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2013-01-27 07:25:57 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2013-01-27 07:25:57 -0800
commite146cfee1b56de1eab711eba984081b3e542fb98 (patch)
tree4222b851fd96b00f96c0acd243c758bf160285d6 /samples/OAuthConsumer/Twitter.aspx.cs
parent24e24a5f60f4f0eb67c5bdc47bea499cbf197fc7 (diff)
downloadDotNetOpenAuth-e146cfee1b56de1eab711eba984081b3e542fb98.zip
DotNetOpenAuth-e146cfee1b56de1eab711eba984081b3e542fb98.tar.gz
DotNetOpenAuth-e146cfee1b56de1eab711eba984081b3e542fb98.tar.bz2
Samples all build now.
Diffstat (limited to 'samples/OAuthConsumer/Twitter.aspx.cs')
-rw-r--r--samples/OAuthConsumer/Twitter.aspx.cs21
1 files changed, 13 insertions, 8 deletions
diff --git a/samples/OAuthConsumer/Twitter.aspx.cs b/samples/OAuthConsumer/Twitter.aspx.cs
index 8288ed0..f418fed 100644
--- a/samples/OAuthConsumer/Twitter.aspx.cs
+++ b/samples/OAuthConsumer/Twitter.aspx.cs
@@ -12,6 +12,8 @@
using DotNetOpenAuth.ApplicationBlock;
using DotNetOpenAuth.OAuth;
+ using DotNetOpenAuth.Messaging;
+
public partial class Twitter : System.Web.UI.Page {
private string AccessToken {
get { return (string)Session["TwitterAccessToken"]; }
@@ -34,7 +36,7 @@
}
}
- protected void Page_Load(object sender, EventArgs e) {
+ protected async void Page_Load(object sender, EventArgs e) {
if (this.TokenManager != null) {
this.MultiView1.ActiveViewIndex = 1;
@@ -42,20 +44,22 @@
var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager);
// Is Twitter calling back with authorization?
- var accessTokenResponse = twitter.ProcessUserAuthorization();
+ var accessTokenResponse = await twitter.ProcessUserAuthorizationAsync(new HttpRequestWrapper(Request), Response.ClientDisconnectedToken);
if (accessTokenResponse != null) {
this.AccessToken = accessTokenResponse.AccessToken;
} else if (this.AccessToken == null) {
// If we don't yet have access, immediately request it.
- twitter.Channel.Send(twitter.PrepareRequestUserAuthorization());
+ var message = await twitter.PrepareRequestUserAuthorizationAsync(Response.ClientDisconnectedToken);
+ var response = await twitter.Channel.PrepareResponseAsync(message, Response.ClientDisconnectedToken);
+ await response.SendAsync();
}
}
}
}
- protected void downloadUpdates_Click(object sender, EventArgs e) {
+ protected async void downloadUpdates_Click(object sender, EventArgs e) {
var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager);
- XPathDocument updates = new XPathDocument(TwitterConsumer.GetUpdates(twitter, this.AccessToken).CreateReader());
+ XPathDocument updates = new XPathDocument((await TwitterConsumer.GetUpdatesAsync(twitter, this.AccessToken, Response.ClientDisconnectedToken)).CreateReader());
XPathNavigator nav = updates.CreateNavigator();
var parsedUpdates = from status in nav.Select("/statuses/status").OfType<XPathNavigator>()
where !status.SelectSingleNode("user/protected").ValueAsBoolean
@@ -77,7 +81,7 @@
this.resultsPlaceholder.Controls.Add(new Literal { Text = tableBuilder.ToString() });
}
- protected void uploadProfilePhotoButton_Click(object sender, EventArgs e) {
+ protected async void uploadProfilePhotoButton_Click(object sender, EventArgs e) {
if (this.profilePhoto.PostedFile.ContentType == null) {
this.photoUploadedLabel.Visible = true;
this.photoUploadedLabel.Text = "Select a file first.";
@@ -85,11 +89,12 @@
}
var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager);
- XDocument imageResult = TwitterConsumer.UpdateProfileImage(
+ XDocument imageResult = await TwitterConsumer.UpdateProfileImageAsync(
twitter,
this.AccessToken,
this.profilePhoto.PostedFile.InputStream,
- this.profilePhoto.PostedFile.ContentType);
+ this.profilePhoto.PostedFile.ContentType,
+ Response.ClientDisconnectedToken);
this.photoUploadedLabel.Visible = true;
}
}