Skip to content

Instantly share code, notes, and snippets.

@sn0opy
Created September 13, 2019 17:58
Show Gist options
  • Save sn0opy/6db61e01f058a15d66818d675956b833 to your computer and use it in GitHub Desktop.
Save sn0opy/6db61e01f058a15d66818d675956b833 to your computer and use it in GitHub Desktop.
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$f3 = Base::instance();
$f3->raidwebhook = null;
$f3->questswebhook = null;
$f3->monwebhook = null;
function send_data($quests, $raids, $mon) {
$f3 = Base::instance();
$client = new Client();
$options = [
'headers' => [
'User-Agent' => 'RDM proxy'
]
];
if ($f3->questswebhook != null && count($quests) > 0) {
$res = $client->post($f3->questswebhook, ['json' => $quests], $options);
}
if ($f3->monwebhook != null && count($mon) > 0) {
$res = $client->post($f3->monwebhook, ['json' => $quests], $options);
}
if ($f3->raidwebhook != null && count($raids) > 0) {
$res = $client->post($f3->raidwebhook, ['json' => $quests], $options);
}
}
function handle_mon($message) {
if ($message['spawnpoint_id'] != "None") {
}
}
$f3->route('POST /', function() use($f3) {
$quests = [];
$raids = [];
$mon = [];
$content = json_decode(file_get_contents('php://input'));
file_put_contents('rdmdata.txt', print_r($content, true)."\n\n", FILE_APPEND);
foreach($content as $message) {
switch($message->type) {
case 'pokemon':
$mon[] = $message;
break;
case 'quest':
$quests[] = $message;
break;
case 'raid':
$raids[] = $message;
break;
}
}
send_data($quests, $raids, $mon);
});
$f3->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment