Simple Server
Ospita in autonomia un leggero backend PHP che rispecchia l'API di horizOn Cloud.
Passaggi di Installazione
- 1Clonare il Repository
Bash Bash1git clone https://github.com/ProjectMakersDE/horizOn-simpleServer.git2cd horizOn-simpleServer3cp .env.example .env - 2Configurare l'Ambiente
Bash Bash1API_KEY=change-me-to-a-secure-key2DB_DRIVER=sqlite3DB_PATH=./data/horizon.db4RATE_LIMIT_ENABLED=true5RATE_LIMIT_PER_SECOND=10 - 3Avviare il Server
Bash Bash1php -S localhost:8080 index.php - 4Verificare l'Installazione
Bash Bash1curl http://localhost:8080/health
Funzionalita API
Creare un Utente
Bash
1curl -X POST http://localhost:8080/api/v1/app/user-management/signup \
2 -H "Content-Type: application/json" \
3 -H "X-API-Key: YOUR_API_KEY" \
4 -d '{"displayName": "TestPlayer"}'
Accedere
Bash
1curl -X POST http://localhost:8080/api/v1/app/user-management/signin \
2 -H "Content-Type: application/json" \
3 -H "X-API-Key: YOUR_API_KEY" \
4 -d '{"anonymousToken": "TOKEN_FROM_SIGNUP"}'
Inviare un Punteggio
Bash
1curl -X POST http://localhost:8080/api/v1/app/leaderboard/submit \
2 -H "Content-Type: application/json" \
3 -H "X-API-Key: YOUR_API_KEY" \
4 -d '{"userId": "USER_UUID", "score": 12500}'
Consultare il Leaderboard
Bash
1curl "http://localhost:8080/api/v1/app/leaderboard/top?limit=10" \
2 -H "X-API-Key: YOUR_API_KEY"
Salvare i Dati di Gioco
Bash
1curl -X POST http://localhost:8080/api/v1/app/cloud-save/save \
2 -H "Content-Type: application/json" \
3 -H "X-API-Key: YOUR_API_KEY" \
4 -d '{"userId": "USER_UUID", "data": "{\"level\":5,\"coins\":1000}"}'
Caricare i Dati di Gioco
Bash
1curl -X POST http://localhost:8080/api/v1/app/cloud-save/load \
2 -H "Content-Type: application/json" \
3 -H "X-API-Key: YOUR_API_KEY" \
4 -d '{"userId": "USER_UUID"}'
Configurazione remota
Bash
1# Get all configs
2curl "http://localhost:8080/api/v1/app/remote-config/all" \
3 -H "X-API-Key: YOUR_API_KEY"
4
5# Get single config
6curl "http://localhost:8080/api/v1/app/remote-config/game.max_level" \
7 -H "X-API-Key: YOUR_API_KEY"
Localizzazione
Bash
1# Get all localizations for a language
2curl "http://localhost:8080/api/v1/app/localization/all?lang=de" \
3 -H "X-API-Key: YOUR_API_KEY"
4
5# Get a single localized string by key
6curl "http://localhost:8080/api/v1/app/localization/menu.play?lang=de" \
7 -H "X-API-Key: YOUR_API_KEY"
Sistema di News
Bash
1curl "http://localhost:8080/api/v1/app/news?limit=10&languageCode=en" \
2 -H "X-API-Key: YOUR_API_KEY"
Codici regalo
Bash
1# Validate
2curl -X POST http://localhost:8080/api/v1/app/gift-codes/validate \
3 -H "Content-Type: application/json" \
4 -H "X-API-Key: YOUR_API_KEY" \
5 -d '{"code": "PROMO2024", "userId": "USER_UUID"}'
6
7# Redeem
8curl -X POST http://localhost:8080/api/v1/app/gift-codes/redeem \
9 -H "Content-Type: application/json" \
10 -H "X-API-Key: YOUR_API_KEY" \
11 -d '{"code": "PROMO2024", "userId": "USER_UUID"}'
Feedback Utenti
Bash
1curl -X POST http://localhost:8080/api/v1/app/user-feedback/submit \
2 -H "Content-Type: application/json" \
3 -H "X-API-Key: YOUR_API_KEY" \
4 -d '{"userId": "USER_UUID", "title": "Bug Report", "message": "Description here"}'
Log Utenti
Bash
1curl -X POST http://localhost:8080/api/v1/app/user-logs/create \
2 -H "Content-Type: application/json" \
3 -H "X-API-Key: YOUR_API_KEY" \
4 -d '{"userId": "USER_UUID", "message": "Player completed tutorial", "type": "INFO"}'
Segnalazione crash
Bash
1# Register session
2curl -X POST http://localhost:8080/api/v1/app/crash-reports/session \
3 -H "Content-Type: application/json" \
4 -H "X-API-Key: YOUR_API_KEY" \
5 -d '{"sessionId": "session-123", "appVersion": "1.0.0", "platform": "Windows"}'
6
7# Submit crash report
8curl -X POST http://localhost:8080/api/v1/app/crash-reports/create \
9 -H "Content-Type: application/json" \
10 -H "X-API-Key: YOUR_API_KEY" \
11 -d '{"type": "CRASH", "message": "NullReferenceException", "fingerprint": "nre-main-loop", "appVersion": "1.0.0", "sdkVersion": "1.0.0", "platform": "Windows", "os": "Windows 11", "deviceModel": "PC", "sessionId": "session-123"}'
Deployment
Deployment Apache
Bash
1# Enable mod_rewrite
2sudo a2enmod rewrite
3sudo systemctl restart apache2
4
5# Virtual host config
6<Directory /var/www/horizOn>
7 AllowOverride All
8</Directory>
Deployment Nginx
Bash
1server {
2 listen 80;
3 server_name your-domain.com;
4 root /var/www/horizOn;
5 index index.php;
6
7 include snippets/horizon.conf;
8}
Configurazione MySQL
Bash
1CREATE DATABASE horizon CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2
3# Update .env:
4# DB_DRIVER=mysql
5# DB_HOST=localhost
6# DB_PORT=3306
7# DB_NAME=horizon
8# DB_USER=your_user
9# DB_PASS=your_password