Closed xiliangliang closed 6 months ago
Currently, there is no direct method for starting a conversation however, here is a workaround
Thread thread = new Thread(jxinsta) // pass the JxInsta reference after login, make sure the login type is MOBILE_AUTHENTICATION
thread.pk = 823652.... // The pk of the use you want to send the message
thread.sendMessage("hi",false);
This will create a new thread with that user. But keep in mind, if the recipient is using the newest Instagram client then you might get error on sending 2nd message. That's because of new Instagram policy that does not allow sending more then one message to a stranger until he/she accepts your DM request.
PS : This code is untested. Please let me know it if does or does not work
Thank you for your reply. I tested according to your method, but there were some errors. Below is my test code and specific errors
JxInsta insta = new JxInsta("samuel.crawford6440870","zayxkdpc6", JxInsta.LoginType.APP_AUTHENTICATION); Thread thread = new Thread(insta); thread.pk=451573056; thread.sendMessage("hi",false);
Exception in thread "main" java.lang.NullPointerException: Cannot read the array length because "this.messages" is null at com.errorxcode.jxinsta.endpoints.direct.Thread.sendMessage(Thread.java:81) at com.fc.test.main(test.java:19)
Looking forward to your reply
after this line,
thread.pk=451573056;
add this,
thread.messages = new Message[0];
That's right, thank you for your reply
We can send messages to someone through threadid, but if I have never sent a message to that person before, how should I create a conversation with them to get the threadid?