Giter Site home page Giter Site logo

linvi / tweetinvi Goto Github PK

View Code? Open in Web Editor NEW
1.0K 59.0 221.0 23.5 MB

Tweetinvi, an intuitive Twitter C# library for the REST and Stream API. It supports .NET, .NETCore, UAP (Xamarin)...

License: MIT License

PowerShell 0.73% C# 90.45% CSS 0.09% JavaScript 7.85% HTML 0.52% Python 0.36% ASP.NET 0.01%
netcore portable twitter csharp dotnet dotnet-core twitter-api twitter-streaming-api twitter-bot twitter-oauth

tweetinvi's People

Contributors

anawaz avatar artsiomkazlouski avatar ashr avatar codenjs avatar gitter-badger avatar gribunin avatar haseeb1431 avatar ievangelist avatar ittybitypixels avatar jiweaver avatar joecklau avatar joshkeegan avatar linvi avatar max-wilkinson avatar nick-wamba avatar on-mx avatar onedeadear avatar piquet-h avatar samusaranx avatar tsconn23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tweetinvi's Issues

Constant 403 exceptions

Hi, I'm constantly getting 403 with "This code is used when requests are being denied due to update limits". On the java forums, folks say you require ssl everywhere and that's what fixed the error. Any thoughts? I'm using 0.9.7.1

Authorization like instagram

i read your documentation about authorization, but my instagram app does not have nether pin nor url based authentication, i think it should a sample like this section

Part 3 - Publishing the Statuses
https://www.develop.com/twitternetapps

your lib does not support this method or i do not find it in documentations

Tweeting with a video returns an error: The tweet cannot be published as some of the medias could not be published

I am tweeting with the video.

Here is the code:

   public static void Tweet_PublishTweetWithVideo()
     {
        string filePath = @"C:\Downloads\Video\1.mp4";
        byte[] file1 = File.ReadAllBytes(filePath);
        var tweet = Tweet.PublishTweetWithVideo("first tweet with video", file1);


     }

How ever this gives me an error: on debugging I found this function returns null.
I get an error: " throw new OperationCanceledException("The tweet cannot be published as some of the medias could not be published!");"

  public IMedia ChunkUploadBinary(byte[] binary, string mediaType)
    {
        var uploader = CreateChunkedUploader();

        if (uploader.Init(mediaType, binary.Length))
        {
            if (uploader.Append(binary))
            {
                return uploader.Complete();
            }
        }

        return null;
    }

Has some one tried and found a solution to this problem? Please help!

Multiple Upload.UploadImage

I m using the latest build from Nuget :0.9.9.6.
It's maybe a problem with the Credentials process. It was working with versions before Tweetinvi 0.9.9.x
The first tweet is well posted but i ve got an error and the second one :
Object reference not set to an instance of an object on :
var media = Upload.UploadImage(imageBytes);

public class TwitterList
{
    public double longitude { get; set; }
    public double latitude { get; set; }
    public string Message { get; set; }
}
public async Task PostAlert(double longitude, double latitude, string Message)
{
    List<TwitterList> AlertList = new List<TwitterList>();
    AlertList.Add(new TwitterList { latitude = 37.386052, longitude = -122.083851, Message = "Test message 1 : " + DateTime.Now });
    AlertList.Add(new TwitterList { latitude = 42.386052, longitude = -122.083851, Message = "Test message 1 : " + DateTime.Now });

    foreach (var item in AlertList)
    {
        await PostTwitterAlert(item.longitude, item.latitude, item.Message);
        Response.Write(item.Message + "<br/>");
    }
}
public async Task PostTwitterAlert(double longitude, double latitude, string Message)
{
    try
    {
        var webClient = new WebClient();
        string GoogleUrl = "http://maps.google.com/maps/api/staticmap?center=" + latitude.ToString() + "," + longitude.ToString() + "&zoom=7&markers=label:E|" + latitude.ToString() + "," + longitude.ToString() + "&size=500x400&sensor=true";
        byte[] imageBytes = webClient.DownloadData(new Uri(GoogleUrl));
        var credentials = new TwitterCredentials("CONSUMER_KEY", "CONSUMER_SECRET", "ACCESS_TOKEN", "ACCESS_TOKEN_SECRET");

        var media = Upload.UploadImage(imageBytes);

        Coordinates Coordinates = new Coordinates(longitude, latitude);
        var tweet2 = Auth.ExecuteOperationWithCredentials(credentials, () =>
        {
            return Tweet.PublishTweet(Message, new PublishTweetOptionalParameters
            {
                Coordinates = Coordinates,
                Medias = new List<IMedia> { media }

            });
        });
    }
    catch (WebException e)
    {
        var exceptionStatusCode = Tweetinvi.ExceptionHandler.GetLastException().StatusCode;
        var exceptionDescription = Tweetinvi.ExceptionHandler.GetLastException().TwitterDescription;
        var exceptionDetails = Tweetinvi.ExceptionHandler.GetLastException().TwitterExceptionInfos.First().Message;
        Response.Write(exceptionDetails);
    }
}

How can reply other tweet?

my code

      var tweetToReplyTo = Tweet.GetTweet(631794399131881472);
        var tweet = Tweet.PublishTweet("We love you back!", new PublishTweetOptionalParameters
        {

            InReplyToTweetId = tweetToReplyTo.Id
        });

Cannot get it to work, prints done but nothing works! does not send a tweet!

using System;
using Tweetinvi;
using Tweetinvi.Core.Credentials;

namespace TweetTry
{
class Program
{
static void Main(string[] args)
{
applicationMenu ();

    }

    static void applicationMenu()
    {
        ITwitterCredentials credentials = Auth.SetUserCredentials (Consumer Key, ConsumerSecret, AccessToken, AccessTokenSecret);

        Console.WriteLine ("Select an action");
        Console.WriteLine ("1. Tweet\n2. Get Timeline\n3. Get Logged User");
        string input = Console.ReadLine ();
        try
        { 
        if (input == "1")
        {
            Tweet.PublishTweet ("@1o1reasons Thanks for the info");
            Console.WriteLine ("Done");
        }

        else if (input == "2")
        {
            var tweets = Timeline.GetHomeTimeline();

                Console.WriteLine (tweets.ToString());

        }

        else
        {
            var loggedUser = User.GetLoggedUser(credentials);
            Console.WriteLine (loggedUser.ToString ());
        }
        Console.ReadLine ();
        }
        catch (Exception ex)
        {
            Console.WriteLine (ex.Message);
            Console.ReadLine ();
        }
    }
}

}

PublishTweetWithImage not working when calling from a web site

Hi,
I've been trying to post a Tweet with an image but it hungs in this line:

Class:HttpClientWebHelper
Method: return await client.PostAsync(twitterQuery.QueryURL, httpContent);

This only happens when I called it from a site. If I used it in a Console application, like in your examples, it sucessfully post the tweet with the media.

Thanks you in advance.

Tweet not push with coordinates

If i use coordinates

var France = new Coordinates(48.869702, 2.342528);
var tweet = Tweet.PublishTweet("Some love from France!", new PublishTweetOptionalParameters
{
    Coordinates = France
});

tweet = null

without coordinates all works

Add new field to help/configuration

Hi Linvi,
Twitter has added a new "dm_text_character_limit" field to help/configuration (added in the build up to increasing the Direct Message size limit, see #46).
Can this be exposed through Tweetinvi?
Cheers,
Josh

PublishTweetInReplyTo for tweet received over Stream creates new tweet instead of reply

I am receiving tweets from the User Stream:

        var stream = Stream.CreateUserStream();
        stream.TweetCreatedByAnyoneButMe += OnTweetCreated;
        await stream.StartStreamAsync();

The event handler processes the tweet then attempts to send a reply back to the user:

    private async static void OnTweetCreated(object sender, TweetReceivedEventArgs e)
    {
            // Do something with the tweet

            Tweet.PublishTweetInReplyTo("Thanks for your request!", e.Tweet);
    }

Unfortunately, it would appear that the reply is simply just a new tweet, and is not attached to the original tweet in the timeline.

See attached screenshot showing reply as new tweet rather than actual reply.

capture

[ADMIN] Limited support between the 13/08 to the 26/08

Hello,

I am taking some time off for the summer holidays. During this time I won't be able to fix any bug (critical or minor), provide any help or advice. I will try to take a look to the page as soon as I will have an internet connection. In meantime please consider the following schedule:

Holidays

  • 13/08 to 21/08 : Probably no internet connection at all - if you encounter a critical bug please rollback to version 0.9.8.2 available on nuget and codeplex.
  • 21/08 to 26/08 : Very limited internet access - I will probably be able to have a look on the isses if any and help you. Help will be provided only for critical bugs.

Please do no be shy to post any issue, suggestion... I will review all of them when I get back.

Cheers,
Linvi

Add documentation to public models

In addition to static methods, we want the models to provide additional information on the content that a classical developer have access to.

TwitterCredentials: 2 parameters or 0?

I am looking at the documentation for TwitterCredentials here:
https://github.com/linvi/tweetinvi/wiki/Authentication
Specifically, this LOC:
var appCredentials = new TwitterCredentials("CONSUMER_KEY", "CONSUMER_SECRET");

The problem is that I only see this in object explorer
Tweetinvi.TwitterCredentials.TwitterCredentials()

And
Tweetinvi.TwitterCredentials.SetCredentials(string, string, string, string)

Is the documentation out of date?
Thanks

Search.SearchUsers

Methods Search.SearchUsers, after first call, very often fails, with a System.NullReferenceException.

Full Text Direct Messages

Hi Linvi,
Twitter has (relatively) recently upped the limit on the length of Direct Messages from 140 chars to 10,000.
For compatibility, the REST API limits messages to 140 chars unless you specify you want to use the new higher limit by adding "full_text=true" as a query param.
Could this functionality be added to Tweetinvi?
You can see the full details at https://twittercommunity.com/t/removing-the-140-character-limit-from-direct-messages/41348

Apologies if I've missed something and this is already implemented.
Cheers,
Josh

Streams only return maximum one tweet for Windows Phone 8.1

I'm using Visual Studio Express 2013 on a Windows 10 machine.

To replicate:
Create an default WP8.1 app or a Universal app.
Add Tweetinvi to WP project using NuGet package manager.
Add this code:

Auth.SetUserCredentials("", "", "", "");
var fs = Tweetinvi.Stream.CreateSampleStream();
fs.TweetReceived += 
    (sender, args) =>
    {
        Debug.WriteLine("Tweet Received");
    };
fs.StartStream();

This only returns 0-1 tweets and after a few minutes the StreamStopped callback is called with the exception:

Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Tweetinvi.Logic.TwitterQuery' can be invoked with the available services and parameters:
Cannot resolve parameter 'System.String queryURL' of constructor 'Void .ctor(System.String, Tweetinvi.Core.Enum.HttpMethod)'.
   at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.Execute()
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Activators.Reflection.AutowiringParameter.<>c__DisplayClass2.<CanSupplyValue>b__0()
   at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
   at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.Execute()
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.ResolveOperation.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
   at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.Resolve[TService](IComponentContext context, IEnumerable`1 parameters)
   at Tweetinvi.Injectinvi.AutofacThreadContainer.Resolve[T](IConstructorNamedParameter[] parameters)
   at Tweetinvi.Injectinvi.AutofacContainer.Resolve[T](IConstructorNamedParameter[] parameters)
   at Tweetinvi.Core.Injectinvi.Factory`1.Create(IConstructorNamedParameter[] parameters)
   at Tweetinvi.Streams.StreamTask.GetJsonResponseFromReader()
   at Tweetinvi.Streams.StreamTask.Start()

The exact same code works fine in ordinary Windows 8.1 apps. I haven't tried yet with VS 2015.
Might be related to:
https://tweetinvi.codeplex.com/workitem/2619

Successful publish but returns an error

I get a lot of successful publishes when calling PublishTweet or PublishTweetWithMedia, but when checking for an exception afterwards like so:
if (ExceptionHandler.GetLastException() != null)
var exceptionDescription = ExceptionHandler.GetLastException().TwitterDescription;

I get "Bad Request - The request was invalid or cannot be otherwise served. An accompanying error message will explain further. In API v1.1, requests without authentication are considered invalid and will yield this response."

I can see I'm passing the twitter token and secret key and some posts return no error and some do. What would make some posts go through and some not?

Issue with GetUsersFromIds and null data

Hey,

Try out this little code snippet:

Auth.SetUserCredentials("xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx");
var z = Tweetinvi.User.GetUsersFromIds(new List<long> { 1, 2, 3 }); // or any twitter Id's that do not exist

This will error yielding the following:

Value cannot be null.
at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
at Tweetinvi.Factories.User.UserFactoryQueryExecutor.GetUsersDTOFromIds(IEnumerable`1 userIds)
at Tweetinvi.Factories.User.UserFactory.GetUsersFromIds(IEnumerable`1 userIds)
at Tweetinvi.User.GetUsersFromIds(IEnumerable`1 userIds)

If you put a twitter id that is known to exist with the other Id's that are known to NOT exist:

Auth.SetUserCredentials("xxxxxx", "xxxxxx", "xxxxxx", "xxxxxx");
var z = Tweetinvi.User.GetUsersFromIds(new List<long> { 783214, 1, 2, 3 });

... everything works as expected.

Remove factory methods from static classes

Static classes are already quite big. Doing so will reduce the number of methods and instead users will now be able to new up parameters.

This is a breaking change that needs to be done for version 1.0.

Unable to publish with image if tweet contains a URL

I have an image to tweet and the tweet text contains a URL.
I shorten the url using google url shortener before I add it to the tweet text.
The total length of the tweet text with the shortened URL in it is 131.
Tried both PublishTweetWithImage and publish with optional paramters (Medias) both fail to publish.

If I simply remove the URL from the tweet text, the tweet succeeds and the image is published.
If I remove the image and publish just the text with the URL, the tweet succeeds.

It is only when a URL exists in the text of the tweet AND you try to publish with image that the tweet fails.

Note: failure is always indicated in the returned ITweet by:
'((Tweetinvi.Logic.Tweet)response).PublishedTweetLength' threw an exception of type 'System.InvalidOperationException'

Note also that I use TweetLength to verify that the tweet text is 131 just prior to the publish operation. IOW: the url has already been shortened and the total text including the shortened URL is 131

ChunkedUploader / UploadVideo / PublishTweetWithVideo all hang on upload

All variations of uploading a video (video size is less than 500kb) appear to hang when calling "Append". This includes:

// 1
var media = Upload.UploadVideo(video);
// 2
var uploader = Upload.CreateChunkedUploader();
var initSucceeded = uploader.Init("video/mp4", video.Length);
var success1 = uploader.Append(video);
var media = uploader.Complete();
// 3
var twit = Tweet.PublishTweetWithVideo(tweet, video);

The line uploader.Append(video); hangs, all other methods never return.

Upon inspection by Fiddler, the Twitter API is returning perfectly fine with a HTTP 204 status code, and looking into the code (only on Github, sorry I haven't had the chance to download and debug further) I can't see any obvious reason why this would cause an issue.

app auth

Hey Linvi,
Can I log in as an application and use 450 queries instead of 180?

need help.. I can not publish

I'm doing something wrong?

    public ActionResult About()
    {
        String UrlContexto = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;
        // Store the application-only credentials into a variable
        var applicationCredentials = CredentialsCreator.GenerateApplicationCredentials(_consumerKey, _consumerSecret);
        String callBack = UrlContexto + Url.Action("Contact", "Home");
        // Get the URL that the user needs to visit to accept your application
        var url = CredentialsCreator.GetAuthorizationURLForCallback(applicationCredentials, callBack);
        if (url != null)
        {
            return new RedirectResult(url);
        }
        else {
          return View();
        }
    }
    public ActionResult Contact(string oauth_token, string oauth_verifier)
    {
       TwitterCredentials.SetCredentials(oauth_token, oauth_verifier, _consumerKey, _consumerSecret);
       Tweet.PublishTweet("Hello Wolrd Again!");
        return View();
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.