Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scan area for objects #27

Open
Spettacolo83 opened this issue Aug 1, 2016 · 18 comments
Open

Scan area for objects #27

Spettacolo83 opened this issue Aug 1, 2016 · 18 comments

Comments

@Spettacolo83
Copy link

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

@Spettacolo83
Copy link
Author

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
Copy link
Owner

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

@NicklasWallgren
Copy link
Owner

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
Copy link
Author

Spettacolo83 commented Aug 1, 2016

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
Copy link
Collaborator

Ni42 commented Aug 1, 2016

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
Copy link

Skullfox commented Aug 2, 2016

....
$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
Copy link
Owner

NicklasWallgren commented Aug 2, 2016

Replace INSERT_LATITUDE and INSERT_LONGITUDE with valid values.

@Skullfox
Copy link

Skullfox commented Aug 2, 2016

$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
Copy link
Collaborator

Ni42 commented Aug 2, 2016

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

@Skullfox
Copy link

Skullfox commented Aug 2, 2016

Version 5.6.22, should update to v7 asap

@Ni42
Copy link
Collaborator

Ni42 commented Aug 2, 2016

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
Copy link

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

@Skullfox
Copy link

Skullfox commented Aug 4, 2016

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

@Ni42
Copy link
Collaborator

Ni42 commented Aug 4, 2016

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

@Spettacolo83
Copy link
Author

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
Copy link

jimmcq commented Aug 11, 2016

Is map data working now? or no?

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

@Ni42
Copy link
Collaborator

Ni42 commented Aug 11, 2016

Nope, needs to wait for #65

@Spettacolo83
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants