Skip to content

Direct Messaging

Rahil khan edited this page Mar 14, 2024 · 2 revisions

This library supports direct messaging with mobile authentication. This means you will need a bearer token to use this. Let us explore some of the methods:

Getting a thread

First of all, get a thread

DirectMessaging dm = insta.directMessaging();
Thread thread = dm.getThread("threadID");
thread.sendMessage("Hello world",  true);
thread.unsend("messageID");
thread.markSeen();

and then do whatever you want.

To get a list of threads in your inbox:

List<Thread> threads = dm.listThreads(numberOfThreads,numberOfMsgPerThread);

To get messages of a thread:

List<Message> messages = thread.getMessages(50);

This method follows auto pagination, which means, that every call of this method will return you the next messages from the thread.

You can now get all the info about the message like this,

String message = messages.get(0).message;

Note: If the itemType is media, then the message will be the download link of that media, text otherwise.

That's all

That's all you need to know about the direct messaging of JxInsta.

Clone this wiki locally