tweetinvi
tweetinvi copied to clipboard
WebhookRequestFactory Reference Error
WebhookRequestFactory is throwing an error because it uses Abstractions 3.1.0.0 - but the highest I can get is 2.2.0.0?
Plugins.Add<AspNetPlugin>();
var appClient = new TwitterClient(appCredsWithBearerToken);
var userClient = new TwitterClient(userCreds);
var accountActivityHandler = appClient.AccountActivity.CreateRequestHandler();
var httpServer = new SimpleHttpServer(8042);
httpServer.OnRequest += async (sender, context) =>
{
var webhookRequest = WebhookRequestFactory.Create(context);
// check if the request comes from twitter
if (await accountActivityHandler.IsRequestManagedByTweetinviAsync(webhookRequest))
{
// let tweetinvi manage the twitter requests and respond to it
await accountActivityHandler.TryRouteRequestAsync(webhookRequest);
}
else
{
// a request not coming from twitter (probably for a user of your website)
var streamWriter = new StreamWriter(context.Response.OutputStream);
await streamWriter.WriteAsync("Hello friend, this page does not exists!");
await streamWriter.FlushAsync();
context.Response.StatusCode = 404;
context.Response.Close();
}
};
httpServer.Start();
await httpServer.WaitUntilDisposed();
Try add this to your project file
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>