This project has moved. For the latest updates, please go here.

Tweeting with Media

Sends a status update with attached media.
Signature:
public async Task<Status> TweetWithMediaAsync(
    string status, bool possiblySensitive, byte[] image)
public async Task<Status> TweetWithMediaAsync(
    string status, bool possiblySensitive, decimal latitude, 
    decimal longitude, string placeID, bool displayCoordinates, byte[] image)

public async Task<Status> ReplyWithMediaAsync(
    ulong inReplyToStatusID, string status, bool possiblySensitive, byte[] image)
public async Task<Status> ReplyWithMediaAsync(
    ulong inReplyToStatusID, string status, bool possiblySensitive, 
    decimal latitude, decimal longitude, string placeID, 
    bool displayCoordinates, byte[] image)
Parameters/Filters:
Name Purpose Type Required
displayCoordinates Display coordinates or not bool no
latitude Status location latitude decimal no
longitude Status location longitude decimal no
image Image bytes byte[] yes
placeID Twitter place ID string no
possiblySensitive Sensitive to audiences or not bool no
status Text of status to send string yes


Return Type: Status
v3.0 Example:
            string status = 
                "Testing TweetWithMedia #Linq2Twitter £ " + 
                DateTime.Now.ToString(CultureInfo.InvariantCulture);
            const bool PossiblySensitive = false;
            const decimal Latitude = TwitterContext.NoCoordinate; //37.78215m;
            const decimal Longitude = TwitterContext.NoCoordinate; // -122.40060m;
            const bool DisplayCoordinates = false;
            const string PlaceID = null;
            const string ReplaceThisWithYourImageLocation = 
                @"..\..\images\200xColor_2.png";

            byte[] imageBytes = 
                File.ReadAllBytes(ReplaceThisWithYourImageLocation);

            Status tweet = await twitterCtx.TweetWithMediaAsync(
                status, PossiblySensitive, Latitude, Longitude,
                PlaceID, DisplayCoordinates, imageBytes);

            if (tweet != null)
                Console.WriteLine(
                    "Media item sent - Tweet Text: " + tweet.Text);
v2.1 Example:
            string status = "Testing TweetWithMedia #Linq2Twitter £ " +
                DateTime.Now.ToString(CultureInfo.InvariantCulture);
            const bool PossiblySensitive = false;
            const decimal Latitude = StatusExtensions.NoCoordinate; //37.78215m;
            const decimal Longitude = StatusExtensions.NoCoordinate; // -122.40060m;
            const bool DisplayCoordinates = false;

            const string ReplaceThisWithYourImageLocation = @"..\..\images\200xColor_2.png";

            var mediaItems =
                new List<Media>
                {
                    new Media
                    {
                        Data = Utilities.GetFileBytes(ReplaceThisWithYourImageLocation),
                        FileName = "200xColor_2.png",
                        ContentType = MediaContentType.Png
                    }
                };

            Status tweet = twitterCtx.TweetWithMedia(
                status, PossiblySensitive, Latitude, Longitude, 
                null, DisplayCoordinates, mediaItems, null);

            Console.WriteLine("Media item sent - Tweet Text: " + tweet.Text);

Twitter API: statuses/update_with_media

Last edited Nov 29, 2013 at 4:50 AM by JoeMayo, version 4