summaryrefslogtreecommitdiffstats
path: root/samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2013-02-09 23:35:41 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2013-02-09 23:35:41 -0800
commitbfb7f04a6c71b54b27763eccf69c3d26c0764272 (patch)
tree13fab874e73a1cf753abcbf1e2d2f40a84bfdc82 /samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs
parent9a0f8c7233f2f42653a9d38255a32f79e34fa985 (diff)
downloadDotNetOpenAuth-bfb7f04a6c71b54b27763eccf69c3d26c0764272.zip
DotNetOpenAuth-bfb7f04a6c71b54b27763eccf69c3d26c0764272.tar.gz
DotNetOpenAuth-bfb7f04a6c71b54b27763eccf69c3d26c0764272.tar.bz2
Fixes OAuthConsumer twitter sample.
Diffstat (limited to 'samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs')
-rw-r--r--samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs14
1 files changed, 9 insertions, 5 deletions
diff --git a/samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs b/samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs
index 455ccf3..0e5387f 100644
--- a/samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs
+++ b/samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs
@@ -13,6 +13,7 @@ namespace DotNetOpenAuth.ApplicationBlock {
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
+ using System.Runtime.Serialization.Json;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
@@ -24,6 +25,8 @@ namespace DotNetOpenAuth.ApplicationBlock {
using DotNetOpenAuth.OAuth;
using DotNetOpenAuth.OAuth.ChannelElements;
+ using Newtonsoft.Json.Linq;
+
/// <summary>
/// A consumer capable of communicating with Twitter.
/// </summary>
@@ -57,7 +60,7 @@ namespace DotNetOpenAuth.ApplicationBlock {
/// <summary>
/// The URI to get the data on the user's home page.
/// </summary>
- private static readonly MessageReceivingEndpoint GetFriendTimelineStatusEndpoint = new MessageReceivingEndpoint("http://twitter.com/statuses/friends_timeline.xml", HttpDeliveryMethods.GetRequest);
+ private static readonly MessageReceivingEndpoint GetFriendTimelineStatusEndpoint = new MessageReceivingEndpoint("https://api.twitter.com/1.1/statuses/home_timeline.json", HttpDeliveryMethods.GetRequest);
private static readonly MessageReceivingEndpoint UpdateProfileBackgroundImageEndpoint = new MessageReceivingEndpoint("http://twitter.com/account/update_profile_background_image.xml", HttpDeliveryMethods.PostRequest | HttpDeliveryMethods.AuthorizationHeaderRequest);
@@ -130,14 +133,15 @@ namespace DotNetOpenAuth.ApplicationBlock {
}
}
- public static async Task<XDocument> GetUpdatesAsync(
+ public static async Task<JArray> GetUpdatesAsync(
ConsumerBase twitter, string accessToken, CancellationToken cancellationToken = default(CancellationToken)) {
var request = await twitter.PrepareAuthorizedRequestAsync(GetFriendTimelineStatusEndpoint, accessToken, cancellationToken);
using (var httpClient = twitter.Channel.HostFactories.CreateHttpClient()) {
using (var response = await httpClient.SendAsync(request)) {
- using (var stream = await response.Content.ReadAsStreamAsync()) {
- return XDocument.Load(XmlReader.Create(stream));
- }
+ response.EnsureSuccessStatusCode();
+ string jsonString = await response.Content.ReadAsStringAsync();
+ var json = JArray.Parse(jsonString);
+ return json;
}
}
}