{$views} views
Hashtags: {$hastags_str}
EOD;
$this->items[] = $item;
}
}
public function getURI()
{
switch ($this->queriedContext) {
case 'By user':
return self::URI . '/' . $this->processUsername();
default:
return parent::getURI();
}
}
public function getName()
{
switch ($this->queriedContext) {
case 'By user':
return $this->feedName . ' (' . $this->processUsername() . ') - TikTok';
default:
return parent::getName();
}
}
private function processUsername()
{
$username = trim($this->getInput('username'));
if (preg_match('#^https?://www\.tiktok\.com/@(.*)$#', $username, $m)) {
return '@' . $m[1];
}
if (substr($username, 0, 1) !== '@') {
return '@' . $username;
}
return $username;
}
public function detectParameters($url)
{
if (preg_match('/tiktok\.com\/(@[\w]+)/', $url, $matches) > 0) {
return [
'context' => 'By user',
'username' => $matches[1]
];
}
return null;
}
}