-
Notifications
You must be signed in to change notification settings - Fork 5
/
ajax.php
45 lines (45 loc) · 1.34 KB
/
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
38
39
40
41
42
43
44
45
<?php
require_once __DIR__ . "/constants.php";
require_once INC_DIR . "functions.php";
$config = include CONFIG_DIR . "config.php";
header("Content-Type: application/json");
header("Cache-Control: no-cache");
header("Connection: close");
error_reporting(E_ALL);
if (isset($_GET['search']) && !empty($_GET['search'])) {
$search = get_param('search');
$type = get_param('type');
$api = new \TikTok\Api(["license-key"=>get_option('license_key')]);
switch ($type) {
case "url":
$data = $api->getVideoByUrl($search);
if ($data) {
echo json_encode($data);
exit;
}
break;
case "user":
$data = $api->getUserFeed($search, get_param('max', 0));
if ($data) {
echo json_encode($data);
exit;
}
break;
case "challenge":
$data = $api->getChallengeFeed($search, get_param('max', 0));
if ($data) {
echo json_encode($data);
exit;
}
break;
case "music":
$data = $api->getMusicFeed($search, get_param('max', 0));
if ($data) {
echo json_encode($data);
exit;
}
break;
}
}
echo json_encode(["error"=>true]);
exit;