Skip to content
View in the app

A better way to browse. Learn more.

OldStyle Gaming Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
  • Administrator

Lucrez la o metoda prin care puteti sa trimiteti catre api prin POST o lista cu multiple servere si aceasta returneaza inapoi json.

Link-ul este gapi.pbcv.dev/get/multiple si lista trebuie trimisa prin POST folositi ce vreti voi php curl, nodejs, python, etc.

 

Exemplu de script PHP, acesta ia serverele din baza de date apoi tirmite lista cu toate catre api.

Datele primine inapoi din api sunt stocate in $response de acolo faceti ce vreti voi cu ele, update la db-ul vostru etc.

<?php
// Start the timer
$startTime = microtime(true);

$dbHost = 'localhost';
$dbUser = 'user';
$dbPass = 'pass';
$dbName = 'dbname';
$charset = 'utf8mb4';

$dsn = "mysql:host=$dbHost;dbname=$dbName;charset=$charset";
$options = [
  PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
  PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
  PDO::ATTR_EMULATE_PREPARES   => false,
];

try {
  $pdo = new PDO($dsn, $dbUser, $dbPass, $options);
} catch (\PDOException $e) {
  throw new \PDOException($e->getMessage(), (int)$e->getCode());
}

try {
  $stmt = $pdo->query('SELECT server FROM servers'); // Modificati dupa cum aveti voi setata coloana cu ip:port
  $servers = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);

  $jsonData = json_encode(array("servers" => $servers));
  $url = 'https://gapi.pbcv.dev/get/multiple';

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($jsonData)
  ));

  $response = curl_exec($ch);

  if (curl_errno($ch)) {
    echo 'cURL error: ' . curl_error($ch);
  } /* else {
    //header('Content-Type: application/json');
    echo $response;
  } */

  curl_close($ch);

} catch (\PDOException $e) {
  error_log('Select query error: ' . $e->getMessage());
}

// End the timer and calculate the duration
$endTime = microtime(true);
$executionTime = $endTime - $startTime;
echo "\nExecution time: " . $executionTime . " seconds";

 

Featured Replies

No posts to show

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.