Armax / Pokemon-GO-node-api

Pokemon GO api node.js library
MIT License
875 stars 198 forks source link

Inventory parameter of GetInventory is null #253

Open NelsonGaldeman opened 7 years ago

NelsonGaldeman commented 7 years ago

I've been trying to get inventory items, but the second parameter of GetInventory returns:

{ success: null, inventory_delta: null }

What am I doing wrong? Here is full code.

'use strict';

var PokemonGO = require('./poke.io.js');
var pogo = new PokemonGO.Pokeio();

var location = {
    type: 'coords',
    coords: {
        latitude: -34.60537813731424,
        longitude: -58.366670608520508
    }
};

var username = 'user';
var password = 'password';
var provider = 'ptc';

pogo.init(username, password, location, provider, function(err) {
    if (err) throw err;

    console.log('Current location: ' + pogo.playerInfo.locationName);
    console.log('lat/long/alt: : ' + pogo.playerInfo.latitude + ' ' + pogo.playerInfo.longitude + ' ' + pogo.playerInfo.altitude);

    pogo.GetProfile(function(err, profile) {
        if (err) throw err;

        console.log('Username: ' + profile.username);

        var currency = {};
        for (var i in profile.currency){
            var type = profile.currency[i].type;
            var amount = profile.currency[i].amount;
            if (!amount){
                amount = 0;
            }
            currency[type] = amount;
        }
        console.log('Stardust: ' + currency['STARDUST']);
    });

    pogo.GetInventory(function(err, inventory){
        if (err) throw err;
        var cleanedInventory = { player_stats: null, eggs : [], pokemon: [], items: [] };
        console.log(inventory);
        callback(cleanedInventory);
    });
});
ameyer commented 7 years ago

If it is always null I'm guessing they banned you. But when my account was working I was having issues where it would come back null at times. So I just put this in there just in case:

        if(inventory == null) return;
        if(inventory.inventory_delta == null) return;