NicklasWallgren / PokemonGoAPI-PHP

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

Added logic for checkChallenge getShowChallenge and getChallengeUrl with example. #154

Closed voxx closed 7 years ago

voxx commented 7 years ago

Rough but works.

$checkChallenge = $pokemonGoApi->checkChallenge()->getData();

If player is flagged for captcha this flag will be true, otherwise false. $checkChallenge->getShowChallenge();

If getShowChallenge() is true, you can pull unique captcha url (changes with every request) $checkChallenge->getChallengeUrl();

Once you have the captcha url, you must open it in a new browser window. (tested in firefox). You can use the rough bookmarklet I've referenced in the example to inject javascript into the page to modify the reCaptcha iframe form to spit out the success token, bypassing it's default behavior to pass this response to unity.

Successful captcha completion should result in token being displayed below the captcha solve box in a custom div. The bookmarklet can be modified to send this token to a remote handler for processing, but for now just spits it out to screen.

Need some help adding logic for verifyChallenge verifyChallenge()->setToken($token); submitting this value back through niantic and validating successful token submit with verifyChallenge()->getSuccess();

Anyone care to help out?

-VoxX

voxx commented 7 years ago

CheckChallengeExample.php Screenshot screen shot 2016-10-20 at 8 49 24 am Load Captcha url, Inject script to modify iframe form via bookmarklet and solve captcha manually to obtain challenge token. screen shot 2016-10-20 at 6 17 53 am

Ni42 commented 7 years ago

Nice, I really dislike adding this whole "GUI/Captcha" thing to a (technically) CLI library, but I guess it has to be done. Can't really look at the code for now, but from the screenshots it looks to be working.

voxx commented 7 years ago

@Ni42 Yeah it's really not ideal to have to grind through captcha with gui/bookmarklet, (or user interaction at all) but for now its a viable solution to at least validate captcha flag on user with "getShowChallenge", pull the dynamic captcha url with getChallengeUrl, and provide a user a way to display, solve, and capture the successful challenge token to be submitted back as verifyChallenge. (hopefully)

Another option would be to just send the flagged user's captcha url and niantic google key to 2captcha to solve, which would remove user interaction, but it's not a free solution.

I've toyed around in the past with working around cross domain restrictions with proxy + iframe and host file hacks, but it's typically not very easy to accomplish or very clean either.

For now it would be nice to just be able to display, solve, and verify the captcha to re-enable the api for flagged accounts without having to manually log in to them on device and solve captcha. For this I need verifyChallenge implemented 🙏

NicklasWallgren commented 7 years ago

Nice addition.