first commit
This commit is contained in:
35
api/fetch_website_info.php
Normal file
35
api/fetch_website_info.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* 获取网站信息API接口
|
||||
*/
|
||||
|
||||
header('Content-Type: application/json');
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: POST');
|
||||
header('Access-Control-Allow-Headers: Content-Type');
|
||||
|
||||
require_once '../config/database.php';
|
||||
require_once '../includes/utils.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
http_response_code(405);
|
||||
echo json_encode(['success' => false, 'message' => 'Method not allowed']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
$url = $input['url'] ?? '';
|
||||
|
||||
if (empty($url)) {
|
||||
echo json_encode(['success' => false, 'message' => 'URL is required']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$database = new Database();
|
||||
$db = $database->getConnection();
|
||||
$utils = new Utils($db);
|
||||
|
||||
$result = $utils->getWebsiteInfo($url);
|
||||
|
||||
echo json_encode($result);
|
||||
?>
|
Reference in New Issue
Block a user