NicklasWallgren / PokemonGoAPI-PHP

Pokemon Go API PHP library
BSD 2-Clause "Simplified" License
130 stars 51 forks source link

Scan area for objects #27

Open Spettacolo83 opened 8 years ago

Spettacolo83 commented 8 years ago

Hello there, Is there any method/function to scan your local area for looking for PokeStops, Pokemons or Gyms? Thank you so much!

Spettacolo83 commented 8 years ago

I tried to call this function from NicklasW\PkmGoApi\Services\Request\MapRequestService:

    public function getResources($latitude, $longitude)
    {
        // Retrieve a list of cell ids from the latitude and longitude
        $cellIds = S2::getCellIds($latitude, $longitude);

        // Retrieve the map resources
        $resources = $this->getRequestService()->getResources($latitude, $longitude, $cellIds);

        print_r('Resources: '.$resources);
    }

But it return all the array void:

        forts=>array(
        )
        spawn_points=>array(
        )
        deleted_objects=>array(
        )
        fort_summaries=>array(
        )
        decimated_spawn_points=>array(
        )
        wild_pokemons=>array(
        )
        catchable_pokemons=>array(
        )
        nearby_pokemons=>array(
        )

Do you know how can I fix it?

NicklasWallgren commented 8 years ago

The Map API is not done yet, you'll have to wait a bit more ;)

NicklasWallgren commented 8 years ago

You could try this snippet while you wait.

$application = new ApplicationKernel('INSERT_USER', 'INSERT_PASSWORD', Factory::AUTHENTICATION_TYPE_PTC);

$application->setLocation(INSERT_LATITUDE, INSERT_LONGITUDE);

$map = new Map();
$map->update();

var_dump($map->getPokestops());
Spettacolo83 commented 8 years ago

Thank you so much! If I can help you, let me know!

Only one time getPokestops() gave me a complete array, but now is always void!

That is an example of what I've received:

[0]=>
  object(NicklasW\PkmGoApi\Api\Map\Data\Resources\Fort)#50 (16) {
    ["id":protected]=>
    string(35) "2bb412d263b2457881354a707c779cc6.16"
    ["lastModifiedTimestampMs":protected]=>
    int(1470036347544)
    ["latitude":protected]=>
    float(52.588293)
    ["longitude":protected]=>
    float(-2.115976)
    ["enabled":protected]=>
    bool(true)
    ["type":protected]=>
    int(1)
    ["ownedByTeam":protected]=>
    int(0)
    ["guardPokemonId":protected]=>
    int(0)
    ["guardPokemonCp":protected]=>
    int(0)
    ["gymPoints":protected]=>
    int(0)
    ["isInBattle":protected]=>
    bool(false)
    ["cooldownCompleteTimestampMs":protected]=>
    int(0)
    ["sponsor":protected]=>
    int(0)
    ["renderingType":protected]=>
    int(0)
    ["activeFortModifier":protected]=>
    string(0) ""
    ["lureInfo":protected]=>
    NULL
  }
  [1]=>
  object(NicklasW\PkmGoApi\Api\Map\Data\Resources\Fort)#639 (16) {
    ["id":protected]=>
    string(35) "94dbfe8dfb9d4785a5e6fe10085756f9.16"
    ["lastModifiedTimestampMs":protected]=>
    int(1470047822589)
    ["latitude":protected]=>
    float(52.596062)
    ["longitude":protected]=>
    float(-2.114933)
    ["enabled":protected]=>
    bool(true)
    ["type":protected]=>
    int(1)
    ["ownedByTeam":protected]=>
    int(0)
    ["guardPokemonId":protected]=>
    int(0)
    ["guardPokemonCp":protected]=>
    int(0)
    ["gymPoints":protected]=>
    int(0)
    ["isInBattle":protected]=>
    bool(false)
    ["cooldownCompleteTimestampMs":protected]=>
    int(0)
    ["sponsor":protected]=>
    int(0)
    ["renderingType":protected]=>
    int(0)
    ["activeFortModifier":protected]=>
    string(0) ""
    ["lureInfo":protected]=>
    NULL
  }

Do you know where is the name of the PokeStop?

I look forward to getNearbyPokemon ;)

Ni42 commented 8 years ago

Names are only in the fort details response, which I think is not exposed yet. But I'm also waiting for this to be implemented, I like the clean API already :)

Skullfox commented 8 years ago
....
$application->setLocation(INSERT_LATITUDE, INSERT_LONGITUDE);
$map = new Map();
$map->update();
var_dump($map->getPokestops());
....

Returns the following:

Parse error: syntax error, unexpected 'DEFAULT' (T_DEFAULT), expecting identifier (T_STRING) or class (T_CLASS) in /home/www/..../res/POGOProtos/Map/Fort/FortData.php on line 33

NicklasWallgren commented 8 years ago

Replace INSERT_LATITUDE and INSERT_LONGITUDE with valid values.

Skullfox commented 8 years ago
$application->setLocation(47.466582, 9.750203);
$map = new Map();
$map->update();
var_dump($map->getPokestops());

returns :

Parse error: syntax error, unexpected 'DEFAULT' (T_DEFAULT), expecting identifier (T_STRING) or class (T_CLASS) in /home/www/..../res/POGOProtos/Map/Fort/FortData.php on line 33

Ni42 commented 8 years ago

Which PHP version are you using? This sounds like a very old one.

Skullfox commented 8 years ago

Version 5.6.22, should update to v7 asap

Ni42 commented 8 years ago

I was wrong, it's not the class constants, but a reserved word, just get the newest version. PHP 5.6 should work fine, anyways.

baskettcase commented 8 years ago

Hi @NicklasWallgren any idea on the Map API release date? :)

Skullfox commented 8 years ago

Looks like Niantic changed something again, get no response(empty array) for getPokestops() & getGyms.

Ni42 commented 8 years ago

Yes, they did, and it's pretty heavy. https://www.reddit.com/r/pokemongodev/comments/4w1cvr/pokemongo_current_api_status/

Spettacolo83 commented 8 years ago

The login and getProfileData is still working! Do you know how can I retrieve the "gyms currently conquered" value? I didn't find it! Thanks!

jimmcq commented 8 years ago

Is map data working now? or no?

If it is, an example to get Pokestops and Gyms would be awesome.

Ni42 commented 8 years ago

Nope, needs to wait for #65

Spettacolo83 commented 8 years ago

The old method does not work:

$application->setLocation(47.466582, 9.750203);
$map = new Map();
$map->update();
var_dump($map->getPokestops());

How can I get the list of Pokestops with the new version of API?