API Documentation

Complete API reference for hogMind integration

Endpoint

For local integration, use:

POST /hogmind/api/track // Clean URL (recommended)
POST /hogmind/api/track.php // Direct file access

For external integration, use:

POST https://hogmind.forumfox.org/api/track // External API

Request Headers

Header Value Required
Content-Type application/json Yes

Request Body

The request body must be a JSON object with the following structure:

{
    "username": "string",        // Required: The username that failed to login
    "ip": "string",              // Required: IP address of the attempt
    "device_info": {              // Required: Device information object
        "browser": "string",      // Browser name and version
        "device": "string",        // Device/OS type
        "device_version": "string", // Device/OS version
        "country": "string",      // Country name
        "region": "string",       // Region/State
        "wifi_name": "string"     // WiFi network name (optional)
    }
}

Response

Success Response (200 OK):

{
    "success": true,
    "message": "Attempt tracked successfully",
    "attempts_count": 3,
    "blocked": true  // true if IP was blocked (3+ attempts)
}

Error Response (400 Bad Request):

{
    "success": false,
    "error": "Missing required field: username"
}

PHP Example

// Track failed login attempt
function trackHogMindAttempt($username, $ip, $deviceInfo) {
    $data = [
        'username' => $username,
        'ip' => $ip,
        'device_info' => $deviceInfo
    ];
    
    $options = [
        'http' => [
            'method' => 'POST',
            'header' => 'Content-Type: application/json',
            'content' => json_encode($data)
        ]
    ];
    
    $context = stream_context_create($options);
        // Use '/hogmind/api/track' for local, or 'https://hogmind.forumfox.org/api/track' for external
        $apiUrl = $_SERVER['HTTP_HOST'] . '/hogmind/api/track.php'; // Local endpoint
        $result = file_get_contents(
        'http://' . $apiUrl,
        false,
        $context
    );
    
    return json_decode($result, true);
}

// Usage in login handler
if (!loginUser($username, $password)) {
    // Login failed - track with hogMind
    $deviceInfo = [
        'browser' => getBrowserFromUserAgent($_SERVER['HTTP_USER_AGENT']),
        'device' => getDeviceFromUserAgent($_SERVER['HTTP_USER_AGENT']),
        'device_version' => getDeviceVersion(),
        'country' => getCountryFromIP($_SERVER['REMOTE_ADDR']),
        'region' => getRegionFromIP($_SERVER['REMOTE_ADDR']),
        'wifi_name' => $_POST['wifi_name'] ?? 'Not available'
    ];
    
    trackHogMindAttempt(
        $username,
        $_SERVER['REMOTE_ADDR'],
        $deviceInfo
    );
}

Python Example

import requests
import json

def track_hogmind_attempt(username, ip, device_info):
    # Use '/hogmind/api/track' for local, or 'https://hogmind.forumfox.org/api/track' for external
    url = '/hogmind/api/track'  # Local endpoint (adjust base URL as needed)
    data = {
        'username': username,
        'ip': ip,
        'device_info': device_info
    }
    
    response = requests.post(url, json=data)
    return response.json()
Back to Main