-
Notifications
You must be signed in to change notification settings - Fork 221
Messages
linvi edited this page Nov 18, 2019
·
8 revisions
Private Messages are messages that can be send between 2 users without having to display it publicly on a any Timeline
. As a result all operation related with Messages will be performed through the authenticated user.
var latestMessage = Message.GetLatestMessages();
var receivedMessages = latestMessages.Where(x => x.SenderId != userId);
var sentMessages = latestMessages.Where(x => x.SenderId == userId);esSentParameters);
Get a specific message from its id.
var message = Message.GetExistingMessage(<message_identifier>);
The cursor allow you to iterate over the results returned by Twitter. Please as followed :
var messages = Message.GetLatestMessages(new GetMessagesParameters()
{
Count = 50
}, out var nextCursor).ToList();
if (nextCursor != null)
{
var olderMessages = Message.GetLatestMessages(new GetMessagesParameters()
{
Count = 50,
Cursor = nextCursor
});
messages.AddRange(olderMessages);
}
// Single Line
var message = Message.PublishMessage("Messages Rocks around here!", <user_identifier>);
var imageBinary = File.ReadAllBytes(imgPath);
// Upload the image to Twitter
var uploadMediaParams = new UploadParameters()
{
Binary = imageBinary,
MediaCategory = Tweetinvi.Core.Public.Models.Enum.MediaCategory.DmImage
};
var media = Upload.UploadBinary(uploadMediaParams);
// Publish the DM
var publishMsgParams = new PublishMessageParameters(text, recipientId)
{
AttachmentMediaId = media.MediaId
};
var message = Message.PublishMessage(publishMsgParams);
if (message != null)
{
Console.WriteLine("Message published with ID {0}", message.Id);
}
var publishMsgParams = new PublishMessageParameters("Do you like cheese?", recipientId)
{
QuickReplyOptions = new IQuickReplyOption[]
{
new QuickReplyOption()
{
Label = "Yes",
Description = "Yes, I love cheese!",
Metadata = "1"
},
new QuickReplyOption()
{
Label = "No",
Description = "No, I do not love cheese...",
Metadata = "0"
}
}
};
var message = Message.PublishMessage(publishMsgParams);
if (message != null)
{
Console.WriteLine("Message published with ID {0}", message.Id);
}
// Destroy from static class Message
var success = Message.DestroyMessage(<message_identifier>);
// Destroy from Message object
var success = message.Destroy();
// With an object you can check if the message has been deleted
var isDeleted = message.IsMessageDestroyed;