Skip to content

Commit

Permalink
Demo updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeMayo committed Apr 12, 2020
1 parent 881231e commit f57d698
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
20 changes: 14 additions & 6 deletions Samples/LinqToTwitter5/net46/CSharp/ConsoleSamples/MediaDemos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ static async Task UploadVideoAsync(TwitterContext twitterCtx)
"Testing video upload tweet #Linq2Twitter £ " +
DateTime.Now.ToString(CultureInfo.InvariantCulture);

//Media media = await twitterCtx.UploadMediaAsync(File.ReadAllBytes(@"..\..\images\LinqToTwitterNormalTest.mp4"), "video/mp4", "tweet_video");
Media media = await twitterCtx.UploadMediaAsync(File.ReadAllBytes(@"..\..\images\LinqToTwitterMediumTest.mp4"), "video/mp4", "tweet_video");
//Media media = await twitterCtx.UploadMediaAsync(File.ReadAllBytes(@"..\..\images\LinqToTwitterErrorTest.mp4"), "video/mp4", "tweet_video");
byte[] imageBytes = File.ReadAllBytes(@"..\..\..\images\TwitterTest.mp4");
const ulong JoeMayoUserID = 15411837;
var additionalOwners = new ulong[] { JoeMayoUserID };
string mediaType = "video/mp4";
string mediaCategory = "tweet_video";

Media media = await twitterCtx.UploadMediaAsync(imageBytes, mediaType, additionalOwners, mediaCategory);

Media mediaStatusResponse = null;
do
Expand Down Expand Up @@ -116,9 +120,13 @@ static async Task CreateMetadataAsync(TwitterContext twitterCtx)
"Testing video upload tweet #Linq2Twitter £ " +
DateTime.Now.ToString(CultureInfo.InvariantCulture);

//Media media = await twitterCtx.UploadMediaAsync(File.ReadAllBytes(@"..\..\images\LinqToTwitterNormalTest.mp4"), "video/mp4", "tweet_video");
Media media = await twitterCtx.UploadMediaAsync(File.ReadAllBytes(@"..\..\images\LinqToTwitterMediumTest.mp4"), "video/mp4", "tweet_video");
//Media media = await twitterCtx.UploadMediaAsync(File.ReadAllBytes(@"..\..\images\LinqToTwitterErrorTest.mp4"), "video/mp4", "tweet_video");
byte[] imageBytes = File.ReadAllBytes(@"..\..\..\images\TwitterTest.mp4");
const ulong JoeMayoUserID = 15411837;
var additionalOwners = new ulong[] { JoeMayoUserID };
string mediaType = "video/mp4";
string mediaCategory = "tweet_video";

Media media = await twitterCtx.UploadMediaAsync(imageBytes, mediaType, additionalOwners, mediaCategory);

Media mediaStatusResponse = null;
do
Expand Down
3 changes: 3 additions & 0 deletions Samples/LinqToTwitter5/net46/CSharp/ConsoleSamples/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Net;
using System.Threading.Tasks;
using LinqToTwitter;

Expand All @@ -9,6 +10,8 @@ class Program
{
static async Task Main()
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

try
{
await DoDemosAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ static async Task ReportSpammerAsync(TwitterContext twitterCtx)
{
const string SpammerScreenName = "realDonaldTrump";

User spammer = await twitterCtx.ReportSpamAsync(SpammerScreenName);
User spammer = await twitterCtx.ReportSpamAsync(SpammerScreenName, performBlock: true);

Console.WriteLine("You just reported {0} as a spammer.", spammer.ScreenNameResponse);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
Expand All @@ -15,6 +16,7 @@ public class Startup
{
public Startup(IConfiguration configuration)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
Configuration = configuration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public async Task<ActionResult> BeginAsync()
}
};

// Available in v5.1.0 - you can pass parameters that you can read in Complete(), via Request.QueryString, when Twitter returns
//var parameters = new Dictionary<string, string> { { "my_custom_param", "val" } };
//string twitterCallbackUrl = Request.GetDisplayUrl().Replace("Begin", "Complete");
//return await auth.BeginAuthorizationAsync(new Uri(twitterCallbackUrl), parameters);

string twitterCallbackUrl = Request.Url.ToString().Replace("Begin", "Complete");
return await auth.BeginAuthorizationAsync(new Uri(twitterCallbackUrl));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
Expand All @@ -12,6 +13,8 @@ public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
Expand Down

0 comments on commit f57d698

Please sign in to comment.