dilame / instagram-private-api

NodeJS Instagram private API SDK. Written in TypeScript.
MIT License
5.99k stars 1.14k forks source link

Error when tried the example #124

Closed petriichuk closed 7 years ago

petriichuk commented 7 years ago
fs.js:932
  return binding.unlink(pathModule._makeLong(path));
Error: ENOENT: no such file or directory, unlink '/home/user/instagram-private-api./cookies/

Mycode:

var Client = require('instagram-private-api').V1;
var device = new Client.Device('user');
var storage = new Client.CookieFileStorage(__dirname + './cookies/user.json');

// And go for login
Client.Session.create(device, storage, 'user', 'pass')
    .then(function(session) {
        // Now you have a session, we can follow / unfollow, anything...
        // And we want to follow Instagram official profile
        return [session, Client.Account.searchForUser(session, 'instagram')]   
    })
    .spread(function(session, account) {
        return Client.Relationship.create(session, account.id);
    })
    .then(function(relationship) {
        console.log(relationship.params)
        // {followedBy: ... , following: ... }
        // Yey, you just followed @instagram
    })

I installed the library "instagram-private-api" then created a file test.js and trying to run "node test.js"

borgateo commented 7 years ago

Have you created the cookies folder? Error: ENOENT: no such file or directory

petriichuk commented 7 years ago

I have the folder. Is it just an empty folder cookies? Or I have somehow to get them?

borgateo commented 7 years ago

I usually create also an empty json file: touch your_path/cookies/your_username.json

Naramsim commented 7 years ago

@borteo The script should create the file autonomously