This repository was archived by the owner on Sep 22, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathapi.php
More file actions
74 lines (63 loc) · 2.17 KB
/
Copy pathapi.php
File metadata and controls
74 lines (63 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
* TFF Süper Lig API
*
* Kullanım:
* - Tüm veri: api.php
* - Hafta filtresi: api.php?week=18
* - Sadece puan cetveli: api.php?type=standings
* - Sadece fikstür: api.php?type=fixtures
*/
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
header('Access-Control-Allow-Headers: Content-Type');
include 'tff_superlig_data.php';
// URL parametrelerini al
$type = isset($_GET['type']) ? $_GET['type'] : 'all';
$week = isset($_GET['week']) ? (int)$_GET['week'] : null;
$format = isset($_GET['format']) ? $_GET['format'] : 'json';
// Veri filtresi
$response = [];
switch ($type) {
case 'fixtures':
if ($week !== null) {
$response = array_filter($tff_superlig_data['fixtures'], function($match) use ($week) {
return $match['week'] === $week;
});
$response = array_values($response); // Index'leri sıfırla
} else {
$response = $tff_superlig_data['fixtures'];
}
break;
case 'standings':
$response = $tff_superlig_data['standings'];
break;
case 'clubs':
$response = $tff_superlig_data['clubs'];
break;
case 'top_scorers':
$response = $tff_superlig_data['top_scorers'];
break;
case 'stats':
$response = [
'total_fixtures' => count($tff_superlig_data['fixtures']),
'total_clubs' => count($tff_superlig_data['clubs']),
'total_standings' => count($tff_superlig_data['standings']),
'total_scorers' => count($tff_superlig_data['top_scorers']),
'weeks_count' => count(array_unique(array_column($tff_superlig_data['fixtures'], 'week'))),
'last_update' => $tff_superlig_data['meta']['scraped_at']
];
break;
default:
$response = $tff_superlig_data;
break;
}
// JSON formatında döndür
if ($format === 'json') {
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
} else {
// Plain text format
echo "<pre>" . print_r($response, true) . "</pre>";
}
?>