tweetinvi icon indicating copy to clipboard operation
tweetinvi copied to clipboard

WebhookRequestFactory Reference Error

Open Scobiform opened this issue 3 years ago • 1 comments

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();

Scobiform avatar May 08 '21 10:05 Scobiform

Try add this to your project file

  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>

luisllamasbinaburo avatar Jun 20 '22 16:06 luisllamasbinaburo