Skip to content

Instantly share code, notes, and snippets.

@wschoot
Created July 27, 2016 14:48
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wschoot/01f6d24c83e18ca955d75bcee2633fc4 to your computer and use it in GitHub Desktop.
Save wschoot/01f6d24c83e18ca955d75bcee2633fc4 to your computer and use it in GitHub Desktop.
<?php
// https://raw.githubusercontent.com/rubenmak/PokemonGo-SlackBot/master/locales/pokemon.en.json
$pokemons = json_decode(file_get_contents("pokemon.en.json"), true);
$json = json_decode(file_get_contents("php://input"));
$poke_id = $json->{"message"}->{"pokemon_id"};
$gone = $json->{"message"}->{"disappear_time"};
$poke = $pokemons[$json->{"message"}->{"pokemon_id"}];
$ignore = [
19, // Rattata
20, // Raticate
];
if (!in_array($poke_id, $ignore)) {
$data = "payload=" . json_encode(array(
"channel" => "#pokemon",
"text" => "$poke ($poke_id) found, until". date("H:i:s", $gone),
"icon_emoji" => ":smile:"
));
$url = // your slack webhook link here
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment