Quantcast
Channel: Tweetinvi a friendly Twitter C# library
Viewing all articles
Browse latest Browse all 4126

New Post: PublishRetweet object reference not set

$
0
0
Hi,

I think you have a fair point. Currently Tweetinvi follows the Twitter API which when a retweet is received has the Media field set to null.
Consequently you are trying to access the .Count field of an object which is not referenced.
I might reconsider how to manage null in later versions.

Concerning your issue, I believe this code should work:
            stream.StartStream(token, tweet => {
            if (tweet.Media != null && tweet.Media.Any())
            {
                Console.WriteLine(tweet.Media[0].MediaURL);
                AddTweet(ref tweet);
                tweet.PublishRetweet();
            }
            else
            {
                Console.WriteLine("no url");
            }
            return 1 == 1;
        });
Kind Regards,
Linvi

Viewing all articles
Browse latest Browse all 4126

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>