Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $app->get('/bot/quotes/json', function () use ($app) {
- require 'data.php';
- try
- {
- $client = new GuzzleHttp\Client([
- 'headers' => [
- 'webauth' => webauth
- ]
- ]);
- $response = $client->get('http://' . host . ':' . port . '/dbquery?table=quotes&getKeys');
- $result = $response->getBody();
- $object = json_decode($result);
- $quotes = array();
- foreach($object->table->keylist as $key=>$keys)
- {
- $response = $client->get('http://' . host . ':' . port . '/dbquery?table=quotes&getData=' . $key);
- $result = $response->getBody();
- $object = json_decode($result);
- $timestamp = (json_decode($object->table->value)[2]) / 1000;
- $datum = date('d.m.Y, H:i:s', $timestamp);
- $src = json_decode($object->table->value);
- $quotes[$key] = array_replace($src, array(2 => $datum));
- }
- }
- catch (ClientException $e)
- {
- $response = $e->getResponse();
- $result = $response->getBody();
- $object = json_decode($result);
- echo "Exception has occurred: ". $object->{'error'};
- }
- return json_encode($quotes, JSON_FORCE_OBJECT);
- });
Advertisement
Add Comment
Please, Sign In to add comment