Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

Commit a7f4795

Browse files
committed
update for user endpoints
1 parent 709360c commit a7f4795

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

example/user.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
$api = new \Sovit\TikTokPrivate\Api([
55
"api_key"=>"XXX",
66
]);
7-
$result = $api->getUser("zachking");
7+
$result = $api->getUserFromSearch("zachking");
88
echo json_encode($result, JSON_PRETTY_PRINT);

lib/TikTokPrivate/Api.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Api
5151
private $defaults = [
5252
"proxy" => null,
5353
"cache_timeout" => 3600,
54-
"transform_result" => true,
54+
"transform_result" => false, // transform not recommended as tiktok json structure is always changing and can be broken at any time.
5555
];
5656

5757
/**
@@ -346,8 +346,8 @@ public function getUserFromSearch($username)
346346
throw new \Exception("Invalid Username");
347347
}
348348
$search = $this->searchUser($username);
349-
if ($search !== false && !empty($search->user_list)) {
350-
$result = Util::find($search->user_list, function ($item) use ($username) {
349+
if ($search !== false && !empty($search->data) && isset($search->data[0]->user_list)) {
350+
$result = Util::find($search->data[0]->user_list, function ($item) use ($username) {
351351
return $item->user_info->unique_id === $username;
352352
});
353353
if ($result) {
@@ -591,7 +591,7 @@ public function searchUser($keyword, $cursor = 0)
591591
$result = $this->remote_call("search/user/" . $keyword, [
592592
'maxCursor' => $cursor,
593593
]);
594-
if (isset($result->user_list)) {
594+
if (isset($result->data[0]->user_list)) {
595595
if ($this->cacheEnabled) {
596596
$this->cacheEngine->set($cacheKey, $result, $this->_config['cache_timeout']);
597597
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tiktok-private-api",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "Unofficial TikTok APP API for PHP",
55
"main": "index.js",
66
"directories": {

0 commit comments

Comments
 (0)