Instagram-private-api: Sending direct messages

Created on 19 Jan 2017  路  7Comments  路  Source: dilame/instagram-private-api

Hi.

I'm struggling with sending out direct messages. Haven't found any example yet, but figured out that code might looks something like this:

var Request = require('instagram-private-api/client/v1/request.js');
var Helpers = require('instagram-private-api/helpers.js');
var Client = require('instagram-private-api').V1;
var device = new Client.Device('SOME_ID');
var storage = new Client.CookieFileStorage(__dirname + '/cookies/SOME_ID.json');


Client.Session.create(device, storage, '<some_user>', '<some_passowrd>')
    .then(function(session) {       
        return Client.Thread.configureText(session, {user_name:'<another_user>'},"Some Message"); 
    }) 

However, I keep getting 500 Error from the server. I do believe that the issue is related to the fact that user object has a wrong format, because when I send just an empty object {} instead, the server returns 200.

Any suggestions regarding format or code sample would be great.

Thanks

Most helpful comment

@huttarichard thanks. I looked into previous issues. And

Client.Thread.configureText(session, "user_id","Some Message");

solved the problem

All 7 comments

checkout previous issues... like one from today

@huttarichard thanks. I looked into previous issues. And

Client.Thread.configureText(session, "user_id","Some Message");

solved the problem

@huttarichard I am getting this error.

Unhandled rejection AuthenticationError: Login required to process this request

Can you tell me why?

@rohanoid5 because you need to login to process this request.

i get

Unhandled rejection ParseError: Not possible to parse API response

var Client = require('instagram-private-api').V1;
var device = new Client.Device('myusername');
var storage = new Client.CookieFileStorage(__dirname + '/cookies/myusername.json');
Client.Session.create(device, storage, 'myusername', 'xxx')
    .then(function(session) {
        return Client.Thread.configureText(session, "other_username","Hello, how are you?");
    })

@intergleam
you have to use not other_username but account id

@sblim0126 Hi, what is an account id?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

endquote picture endquote  路  12Comments

prichey picture prichey  路  10Comments

ciolt picture ciolt  路  35Comments

DenisKrsk picture DenisKrsk  路  33Comments

delmotte picture delmotte  路  61Comments