Exemplo n.º 1
0
        public ITweet PublishTweetWithMedia(string text, byte[] media)
        {
            var parameters = new PublishTweetOptionalParameters();
            parameters.MediaBinaries.Add(media);

            return PublishTweet(text, parameters);
        }
Exemplo n.º 2
0
        public ITweet PublishTweetWithMedia(string text, long mediaId)
        {
            var parameters = new PublishTweetOptionalParameters();
            parameters.MediaIds.Add(mediaId);

            return PublishTweet(text, parameters);
        }
Exemplo n.º 3
0
        public PublishTweetParameters(string text, IPublishTweetOptionalParameters optionalParameters = null)
        {
            Text = text;

            if (optionalParameters == null)
            {
                Parameters = new PublishTweetOptionalParameters();
            }
            else
            {
                Parameters = optionalParameters;
            }
        }
Exemplo n.º 4
0
        public PublishTweetParameters(string text, IPublishTweetOptionalParameters optionalParameters = null)
        {
            Text = text;

            if (optionalParameters == null)
            {
                Parameters = new PublishTweetOptionalParameters();
            }
            else
            {
                Parameters = optionalParameters;
            }
        }
Exemplo n.º 5
0
        public static long PublishTweet(string tweet_string,long? inReplyToTweetId)
        {
            Tweetinvi.Core.Interfaces.ITweet newTweet=null;
            if (inReplyToTweetId == 0)
            {
                newTweet = Tweet.PublishTweet(tweet_string);
            }else
            {
                newTweet = Tweet.PublishTweet(tweet_string, new PublishTweetOptionalParameters { InReplyToTweetId = inReplyToTweetId });
            }
            PublishTweetOptionalParameters parameters = new PublishTweetOptionalParameters();
            parameters.InReplyToTweetId = newTweet.Id;

            return newTweet.Id;
            //            newTweet.
        }
Exemplo n.º 6
0
        public ActionResult Index(string tweet, HttpPostedFileBase file)
        {
            var fileBytes = GetByteArrayFromFile(file);

            var publishedTweet = Auth.ExecuteOperationWithCredentials(_credentials, () =>
            {
                var publishOptions = new PublishTweetOptionalParameters();
                if (fileBytes != null)
                {
                    publishOptions.MediaBinaries.Add(fileBytes);
                }

                return Tweet.PublishTweet(tweet, publishOptions);
            });

            var routeValueParameters = new RouteValueDictionary();
            routeValueParameters.Add("id", publishedTweet == null ? (Nullable<long>)null : publishedTweet.Id);
            routeValueParameters.Add("actionPerformed", "Publish");
            routeValueParameters.Add("success", publishedTweet != null);
            return RedirectToAction("TweetPublished", routeValueParameters);
        }
Exemplo n.º 7
0
        public ITweet PublishTweetInReplyTo(string text, long tweetId)
        {
            var parameters = new PublishTweetOptionalParameters();
            parameters.InReplyToTweetId = tweetId;

            return PublishTweet(text, parameters);
        }
Exemplo n.º 8
0
        public ITweet PublishTweetWithVideo(string text, byte[] video)
        {
            var media = _uploadQueryExecutor.UploadVideo(video);
            if (media == null || media.MediaId == null)
            {
                throw new OperationCanceledException("The tweet cannot be published as some of the medias could not be published!");
            }

            var parameters = new PublishTweetOptionalParameters();
            parameters.MediaIds.Add((long)media.MediaId);

            return PublishTweet(text, parameters);
        }
Exemplo n.º 9
0
        public ITweet PublishTweetInReplyTo(string text, ITweetIdentifier tweet)
        {
            var parameters = new PublishTweetOptionalParameters();
            parameters.InReplyToTweet = tweet;

            return PublishTweet(text, parameters);
        }
Exemplo n.º 10
0
        public static void Tweet_PublishTweetWithGeo(string text)
        {
            const double longitude = -122.400612831116;
            const double latitude = 37.7821120598956;

            var publishParameters = new PublishTweetOptionalParameters();
            publishParameters.Coordinates = new Coordinates(longitude, latitude);

            var tweet = Tweet.PublishTweet(text, publishParameters);

            Console.WriteLine(tweet.IsTweetPublished);
        }
Exemplo n.º 11
0
        public static ITweet Tweet_PublishTweetWithImage(string text, string filePath, string filepath2 = null)
        {
            byte[] file1 = File.ReadAllBytes(filePath);

            var publishMultipleImages = filepath2 != null;

            // Create a tweet with a single image
            if (publishMultipleImages)
            {
                var publishParameters = new PublishTweetOptionalParameters
                {
                    MediaBinaries = new[]
                    {
                        file1,
                        File.ReadAllBytes(filepath2)
                    }.ToList()
                };

                return Tweet.PublishTweet(text, publishParameters);
            }
            else
            {
                return Tweet.PublishTweetWithImage(text, file1);
            }
        }