大头清晰 - 图片处理

处理中,请稍候...

API 使用说明

本服务提供 API 接口,方便外部用户集成调用。

接口地址

api.php

请求方式

POST

请求参数

参数名 类型 必填 说明
submit string 提交标识,任意值均可
image file 要处理的图片文件

返回方式

返回JSON格式结果:

成功响应:

{"success": true, "image_url": "处理后的图片URL"}

失败响应:

{"success": false, "error": "错误信息"}

调用示例

curl 示例:

curl -X POST "http://localhost:8000/api.php" \
  -F "submit=1" \
  -F "image=@/path/to/your/image.jpg"

PHP 示例:

<?php
// 注意事项:
// 1. 请将 $imagePath 替换为实际的图片路径
// 2. 确保图片路径在服务器的 open_basedir 允许范围内
// 3. 例如:在服务器上应使用类似 '/www/wwwroot/qingxi.dewu.bar/images/test.jpg' 的路径

// 示例路径 - 请根据实际情况修改
$imagePath = '/www/wwwroot/qingxi.dewu.bar/images/test.jpg';

// 检查文件是否存在
if (!file_exists($imagePath)) {
    die('错误:图片文件不存在');
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost:8000/api.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);

$postFields = [
    'submit' => '1',
    'image' => new CURLFile($imagePath)
];
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);

$response = curl_exec($ch);
curl_close($ch);

// 处理响应(重定向)
?>