Comments (3)
When I try and use
/* Express */
var express = require('express');
var path = require('path');
var app = express();
app.use(express.static(path.join(__dirname, 'public')));
app.get('/', function (req, res) {
res.render("./index.html");
});
app.get('/view', function (req, res) {
//res.render("./index.html");
res.send("<h1>Messages</h1>" + + "<br></br> <a href='http://localhost:3000/view/'>Reload..</a>"));
getDMS();
});
app.get('/dm', function (req, res) {
res.send("Sent to " + req.query['user'] + " as " + req.query['text']
+ "<br></br> <a href='http://localhost:3000/view/'>View this conversation..</a>")
sendDM(req.query['user'], req.query['text']);
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
/* Instagram API */
var PrivateAPI = require('instagram-private-api');
function sendDM(user, text) {
var Client = PrivateAPI.Client.V1;
var device = new Client.Device('SAMSUNG_GALAXY_S2', 'n0tabot');
var cookiePath = './cookies/n0tabot.json';
var session = new Client.Session(device, cookiePath);
var promise = Client.Session.create(device, cookiePath, 'n0tabot', 'dhillon');
promise.then(function(sessionInstance) {
// Search for the User
Client.Account.searchForUser(session, user)
.then(function(accountInstance) {
var userId = accountInstance.id;
// Send a DM
Client.Thread.configureText(session, userId, text)
.then(function(threads) {
var thread = threads[0];
//thread.broadcastText(text);
return thread.items; // -> see conversation
});
});
});
}
function getDMS() {
var ClientProxy = PrivateAPI.ProxyClient.V1;
var server = new ClientProxy.Server('0.0.0.0', '8080', '8888');
var session = new ClientProxy.Session(server);
session.create('n0tabot', 'dhillon')
.then(function(session) {
ClientProxy.Thread.subscribeAll(session, function(thread){
// this -> socket connection
console.log(thread, "thread change");
})
});
}
I get this in the Terminal.app:
Request Error RequestError: Error: unable to get local issuer certificate
at new RequestError (/Users/dhillon/Desktop/NodeJS/InstagramApp/node_modules/request-promise/lib/errors.js:11:15)
at Request.RP$callback as _callback
at self.callback (/Users/dhillon/Desktop/NodeJS/InstagramApp/node_modules/request/request.js:187:22)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at Request.onRequestError (/Users/dhillon/Desktop/NodeJS/InstagramApp/node_modules/request/request.js:813:8)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at TLSSocket.socketErrorListener (_http_client.js:308:9)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
at emitErrorNT (net.js:1272:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
Unhandled rejection Error: store does not support getAllCookies and cannot be serialized
from instagram-private-api.
@dhillon2325 not sure what problem with certificate is all about, but based on previous issue, you were able to reach endpoint, not sure what change. Anyway, if you want to do some development in node.js learn first. No more type of issues "I don't know how to make app..". Go to learn, learn how to build realtime apps in node and how to async programming. After you will be done, you can try this. Questions about node development forward to stackoverflow.com
/* Express */
var express = require('express');
var path = require('path');
var app = express();
var Promise = require('bluebird');
var EXPRESS_APP = 3000;
var PROXY_APP = 8080;
var PROXY_SOCKET = 8888;
app.use(express.static(path.join(__dirname, 'public')));
app.get('/threads', function (req, res) {
getThreads().then(function(threads) {
res.json(threads.map(function(t){return t.params}));
})
});
app.get('/threads/:thread', function(req, res) {
getThread(req.params.thread).then(function(thread){
res.json(thread.params);
})
})
app.listen(EXPRESS_APP, function () {
console.log('Example app listening on port ' + EXPRESS_APP);
});
/* Instagram API */
var PrivateAPI = require('instagram-private-api');
var server = PrivateAPI.ProxyServer;
server.run({
port: PROXY_APP,
socketPort: PROXY_SOCKET,
host: "127.0.0.1",
databaseDir: './databases',
cookiesDir: './cookies'
});
var ClientProxy = PrivateAPI.ProxyClient.V1;
var server = new ClientProxy.Server('127.0.0.1', PROXY_APP, PROXY_SOCKET);
var session = new ClientProxy.Session(server);
var promise = session.create('n0tabot', 'dhillon');
var session;
promise.then(function(sessionInstance) {
session = sessionInstance;
console.log("Session created!");
//ClientProxy.Thread.subscribeAll(session, function(threads) {
// use socket.io (http://socket.io/docs/) in order to get notified when something in inbox
//})
//ClientProxy.Thread.subscribe(session, thread.id, function(thread) {
// use socket.io if you want to build realtime chat app, this will be called every
// time when someone respond to the thread, this wil poll only one thread, so it is much faster
// then subscribeAll which will poll for whole inbox
//})
})
function getThreads() {
if(!session) return Promise.resolve([]);
return ClientProxy.Thread.all(session, 100);
}
function getThread(id) {
if(!session) return Promise.resolve({});
return ClientProxy.Thread.show(session, id, 300);
}
from instagram-private-api.
Okay, thank you I will try this. And I am slowly learning NodeJS 👍
from instagram-private-api.
Related Issues (20)
- Error while uploading the video HOT 1
- collaboration
- How to share post as a story HOT 4
- Original audio is not showing in reels HOT 1
- how to set userAgent ?
- Yazaan.alrbadwi HOT 1
- Timeline not working and more questions
- Cookie login doesn't works HOT 3
- sh
- Device ID and Android 11 HOT 2
- Get the following list of a public user HOT 1
- Example of capturing comments and likes on a post? HOT 3
- Login by email HOT 3
- How to get latest Instagram app constants?
- Get all followers of a channel using followersFeed.items$.subscribe() HOT 1
- Sometimes the code dont send a comment on post
- create account or sign up cannot be process
- From story add to highlight reel HOT 1
- A HOT 2
- Error 400 Bad Request; when posting a photo HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from instagram-private-api.