免费短链接URL重定向API

将短链接URL重定向集成到您的应用程序中,使用我们强大的REST API。以编程方式创建、管理和跟踪您的短链接。

100%免费 闪电般快速 安全可靠

快速开始

创建短链接

curl -X POST https://rdrbx.net/create.php \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "targetUrl=https://example.com&shortCode=my-link"

响应

{
  "success": true,
  "message": "Short link created successfully"
}

API端点

POST /create.php

Create a new short link redirect.

参数

Parameter Type Required Description
targetUrl string Yes The destination URL to redirect to
shortCode string Yes 3-16 characters, letters, numbers, and hyphens only

示例请求

curl -X POST https://rdrbx.net/create.php \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "targetUrl=https://www.google.com&shortCode=google"

成功响应

{
  "success": true,
  "message": "Short link created successfully"
}

错误响应

{
  "success": false,
  "message": "Short code already exists. Please choose a different one."
}

代码示例

JavaScript (Fetch API)

async function createShortLink(targetUrl, shortCode) {
  const baseUrl = window.location.origin;
  const isRdrbxNet = window.location.hostname.includes('rdrbx.net');
  
  try {
    const response = await fetch(baseUrl + '/create.php', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
      },
      body: `targetUrl=${encodeURIComponent(targetUrl)}&shortCode=${encodeURIComponent(shortCode)}`
    });
    
    const result = await response.json();
    
    if (result.success) {
      const shortUrl = isRdrbxNet 
        ? `${baseUrl}/${shortCode}`
        : `${baseUrl}/r/${shortCode}`;
      console.log('Short link created:', shortUrl);
    } else {
      console.error('Error:', result.message);
    }
  } catch (error) {
    console.error('Network error:', error);
  }
}

// Usage
createShortLink('https://www.google.com', 'google');

Python (requests)

import requests

def create_short_link(target_url, short_code, base_url='https://rdrbx.net'):
    url = base_url + '/create.php'
    is_rdrbx_net = 'rdrbx.net' in base_url
    data = {
        'targetUrl': target_url,
        'shortCode': short_code
    }
    
    try:
        response = requests.post(url, data=data)
        result = response.json()
        
        if result['success']:
            short_url = f"{base_url}/{short_code}" if is_rdrbx_net else f"{base_url}/r/{short_code}"
            print(f"Short link created: {short_url}")
        else:
            print(f"Error: {result['message']}")
    except Exception as e:
        print(f"Network error: {e}")

# Usage
create_short_link('https://www.google.com', 'google')

PHP (cURL)

<?php
function createShortLink($targetUrl, $shortCode, $baseUrl = 'https://rdrbx.net') {
    $url = $baseUrl . '/create.php';
    $isRdrbxNet = strpos($baseUrl, 'rdrbx.net') !== false;
    $data = [
        'targetUrl' => $targetUrl,
        'shortCode' => $shortCode
    ];
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    $response = curl_exec($ch);
    curl_close($ch);
    
    $result = json_decode($response, true);
    
    if ($result['success']) {
        $shortUrl = $isRdrbxNet 
            ? "{$baseUrl}/{$shortCode}"
            : "{$baseUrl}/r/{$shortCode}";
        echo "Short link created: {$shortUrl}\n";
    } else {
        echo "Error: {$result['message']}\n";
    }
}

// Usage
createShortLink('https://www.google.com', 'google');
?>

速率限制和指南

速率限制

  • 100 requests per day per IP
  • Resets daily at midnight
  • Fair usage policy applies

最佳实践

  • Use meaningful short codes
  • Validate URLs before sending
  • Handle errors gracefully
  • Cache responses when appropriate

需要帮助?

我们的API设计简单可靠。如果您有任何问题或需要帮助,我们随时为您服务!