-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathajax.php
37 lines (33 loc) · 969 Bytes
/
ajax.php
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
<?php
$data = json_decode(file_get_contents('php://input'), true);
header('Content-Type: application/json; charset=utf-8');
if ($data['url']) {
$url = $data['url'];
if (!empty($url)) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$a = curl_exec($ch);
$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
echo json_encode([
'success' => true,
'message' => 'Url expanded successfully!',
'url' => $url
]);
return;
} else {
echo json_encode([
'success' => false,
'message' => 'Input field(s) are empty!'
]);
return;
}
} else {
echo json_encode([
'success' => false,
'message' => 'Input is not provided'
]);
return;
}