NicklasWallgren / PokemonGoAPI-PHP

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

Use official google/protobuf #135

Closed NicklasWallgren closed 7 years ago

NicklasWallgren commented 7 years ago

"But please understand that the official Proto3 support from google/protobuf for PHP will be ready very soon so my Protobuf-PHP fork will be going away soon."

https://github.com/grpc/grpc/issues/7825

Ni42 commented 7 years ago

Great, that's at least one less dependency to worry about. We'll see how long that will take. Also see comments/milestone for protobuf 3.1.0 at https://github.com/google/protobuf/issues/1936

DrDelay commented 7 years ago

My first tests with the official library were successful, although I had to make use of Composer's include-path directive, what felt a little hacky.

I've put my progress in https://github.com/jaspervdm/pogoprotos-php/commit/5f1930b08afe2b89ac49862a3a7d92c4d6bf73ff.

I've successfully decoded buddyWithoutCandy, it has to be noted though that it failed for the message with UK33 in PokemonData, like it does with the current lib.

This is my "test":

$responseEnvelope = new \POGOProtos\Networking\Envelopes\ResponseEnvelope();
$responseEnvelope->decode(file_get_contents('buddyWithoutCandy.txt'));

/** @var \Google\Protobuf\Internal\RepeatedField $inventResp */
$inventResp = $responseEnvelope->getReturns();

$inventoryResponse = new \POGOProtos\Networking\Responses\GetInventoryResponse();
$inventoryResponse->decode($inventResp->offsetGet(0));

/** @var \POGOProtos\Inventory\InventoryDelta $delta */
$delta = $inventoryResponse->getInventoryDelta();

/** @var \Google\Protobuf\Internal\RepeatedField $items */
$items = $delta->getInventoryItems();

foreach ($items as $item) {
    /** @var \POGOProtos\Inventory\InventoryItem $item */
    /** @var \POGOProtos\Inventory\InventoryItemData $data */
    $data = $item->getInventoryItemData();
    var_dump($data->getPokemonData());
}
NicklasWallgren commented 7 years ago

Resolved.