NicklasWallgren / PokemonGoAPI-PHP

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

Refactor CheckChallengeExample and VerifyChallenge Example. Fix error handling for invalid challange token submission. #156

Closed voxx closed 7 years ago

voxx commented 7 years ago

Changelog:

-Spent some time cleaning up the check and verify challenge examples and refactored the code a bit. (ocd?)

-Added some rough error handling to src/Requests/VerifyChallengeRequest.php to create a dummy verifyChallengeResponse object and set its sucess value to false when an invalid challenge token is submitted. Previously attempt to unmarshall the null response to getReturnsArray() would result in an uncaught exception and prevented a valid "false" json response from being generated.

-Renamed sendChallengeResponse to verifyChallenge in src/Api/PokemonGoApi.php to better reflect its purpose and follow existing api convention.

-Renamed verifyChallenge function to processRequest in VerifyChallengeExample.php to better reflect its purpose.

-Fixed a small bug in the inline bookmarklet script example: missing div ending.

-A dollop of magic fairy dust

voxx commented 7 years ago

@DrDelay @NicklasWallgren Can one of you take a look over this and let me know if you can merge? The error checking addition is pretty useful if you want to try and process more than one request in a loop.