Closed barryvdh closed 8 years ago
I am working on a PHP API that uses this, I managed to get the API endpoint, but it requires some modifications to these classes, see also #2 . I will put up some code in https://github.com/jaspervdm/pogoapi-php that works upto now
I committed my progress to https://github.com/jaspervdm/pogoapi-php , I would be very open to a collaboration to develop a full API!
Looks very promising, I didn't deal with the whole Protobuf API communication at all until now, but will definitely try to understand and get some basic calls to work with this repo tomorrow. :+1:
I tried to integrate your protos into my project (see DrDelay/pokemon-go@bfd6f82997f4aaabf644701d2264dd08cf36f4c3), but am also only getting the 'd"' as response. Did anyone here solve that already :question:
Using pogoapi-php, I was able to get the API endpoint yesterday, but today it's giving me trouble. Do get more then 'd"' though: https://github.com/jaspervdm/pogoapi-php/issues/4
When you fix the auth name, you should get more then d": https://github.com/DrDelay/pokemon-go/pull/2 (But then you get the same as the issue I referenced)
Should be fixed with https://github.com/jaspervdm/pogoprotos-php/pull/4
Can confirm this works for me
Only the results array is still empty (1 item with null, because of the 0 length)
I don't know if it's obvious and everyone already did that, but when you decode the raw response this is empty aswell:
$ protoc --decode_raw < raw.bin
1: 53
2: 1469378659230941184
3: "pgorelease.nianticlabs.com/plfe/193"
7 {
1: "\033\363/\364C\17....\354\261"
2: 1469378213466
3: "\303\2....;\353t\300"
}
100: ""
... -> Removed data from the AuthTicket, my PKMGO account is really precious :laughing:
So we are doing something wrong in the request?
I compared the requests from a working C#-Implementation with this one, and there is a difference that might be the problem: The working one sends the location (in this example longitude) like this: 4632568534467118047 "Ours" sends it like this: 0x40485e646c9122d3
The other one actually calls a function named FloatAsUlong to convert the data.
In a 64-bit PHP Environment you can implement this like that:
unpack('Q', pack('d', $float))[1]
I tried to implement this, but the Proto-file internally calls Protobuf::write_double
that makes it wrong again. There is actually a comment saying BUG We need to convert from machine order to little order first
next to this function.
This is how far I got, hopefully it helps someone to find a solution to this.
Okay, I was actually looking in to that this afternoon, why the Python API was doing that here https://github.com/tejado/pgoapi/blob/master/pgoapi/pgoapi.py
def set_position(self, lat, lng, alt):
self.log.debug('Set Position - Lat: %s Long: %s Alt: %s', lat, lng, alt)
self._position_lat = f2i(lat)
self._position_lng = f2i(lng)
self._position_alt = f2i(alt)
def f2i(float):
return struct.unpack('<Q', struct.pack('<d', float))[0]
I tried passing the raw value from that, but I didn't check the actual sent data.
Also, the note seems to be about little/big endianness. Which they check here for example: https://github.com/drslump/Protobuf-PHP/blob/2201961982bc531a9ab22fc8a150ba815e9b6ef0/library/DrSlump/Protobuf/Codec/Binary/Writer.php#L287-L299 But that doesn't seem to matter for my case.
So should we fix Protobuf::write_double or is the type wrong?
I been working on a library for a while, have a look.
Did you also run in to the above issue, or how did you solve that?
I did not actually, take a look at 'NicklasW\PkmGoApi\Handlers\RequestHandler' to see how I handle the API requests.
I noticed you create the RequestEnvelope in RequestHandler, but never fill in the location (latitude/longitude/altitude). Are you planning on implementing that?
In time, it's on the todo list :)
I feel a little dumb right know. You have to resend the request with the AuthTicket after receiving it.
He is doing it there: https://github.com/NicklasWallgren/PokemonGoAPI-PHP/blob/b1174471a1039c89a23260eedb7f6f45430d8f4d/src/Handlers/RequestHandler.php#L90-L95
Is this actually implemented already somewhere?
I was trying to use this with https://github.com/DrDelay/pokemon-go but couldn't really figure out how to properly do it all. Are you working on something, or is that private?
Otherwise might be an idea to combine? /cc @DrDelay
This wat I was working on, based on https://github.com/ctrlaltdylan/pgo-php/blob/master/app/Models/Http/Client.php and https://github.com/tejado/pgoapi)
But response seems to be just 'd"', not an actual proper something, or even an error message.. (Also saw that you already fixed the
use ProtobufIO
which I also ran into :))