# Setup API su Questo Server Remoto

Guida rapida per configurare questo server come server remoto per FindMy API.

## ⚡ Quick Setup (2 minuti)

### 1. Configura API Key

```bash
cd /var/www/www.carrogwp.com/api/SganaTags/

# Opzione A: Usa lo script automatico (se disponibile)
./setup-api-keys.sh "YOUR-API-KEY-FROM-MASTER"

# Opzione B: Manuale
cp findmy-api-keys.json.example findmy-api-keys.json
nano findmy-api-keys.json  # Inserisci la tua API key
chmod 600 findmy-api-keys.json
```

### 2. Verifica Percorsi Database

Verifica che i percorsi in `api-findmy-daemon.php` (linee 59-62) corrispondano ai tuoi:

```bash
# Verifica percorsi esistenti
ls -la /var/www/findmy-daemon/reports.db
ls -la /home/adminvs/sganaTags/FindMy_SganaTags/RollingKeys/

# Se diversi, modifica api-findmy-daemon.php
nano api-findmy-daemon.php
```

### 3. Test Endpoint

```bash
# Test locale
curl -H "X-API-Key: YOUR-API-KEY" \
  "http://localhost/api/SganaTags/api-findmy-daemon.php?action=daemon-status"

# Deve rispondere con JSON success
```

### 4. Aggiungi al Master

Sul server master:
1. Vai su `dashboard-findmy-apple.php`
2. Tab "Gestione Server"
3. Aggiungi questo server con URL: `https://questo-server.com`

## ✅ Checklist

- [ ] Directory `/var/www/www.carrogwp.com/api/SganaTags/` esiste
- [ ] File `api-findmy-daemon.php` presente
- [ ] File `findmy-api-keys.json` configurato con chiave valida
- [ ] Permessi `findmy-api-keys.json` = 600 (owner: www-data)
- [ ] File `.htaccess` presente (protegge i .json)
- [ ] Percorsi database corretti in `api-findmy-daemon.php`
- [ ] Test curl locale funziona
- [ ] Server aggiunto al dashboard master
- [ ] Dashboard master si connette (status: "Connesso")

## 🔍 Troubleshooting

### Test non funziona (401)
API key errata → Verifica `findmy-api-keys.json`

### Database non trovato
Percorsi errati → Modifica linee 59-62 in `api-findmy-daemon.php`

### File JSON accessibili via browser
.htaccess non funziona → Verifica AllowOverride in Apache config

## 📚 Documentazione Completa

Vedi `/admin-panel/` sul server master per:
- SETUP-FINDMY-API.md
- README-FINDMY-API.md
- TESTING-FINDMY-API.md

---

**Server Type:** Remote API Server  
**API Endpoint:** `https://questo-server.com/api/SganaTags/api-findmy-daemon.php`  
**Status:** ⏳ In configurazione
