From 7dbf8e576b7a03fe314625378da692f7757cbfba Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 29 Dec 2021 22:05:49 +0200 Subject: [PATCH] add new methods --- src/system/twister.php | 131 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/src/system/twister.php b/src/system/twister.php index a3c3995..76e77b8 100644 --- a/src/system/twister.php +++ b/src/system/twister.php @@ -109,6 +109,137 @@ class Twister { return false; } + public function getPosts(string $userNameRecipient, string $userNameSender, int $limit) { + + $this->_curl->prepare( + '/', + 'POST', + 30, + [ + 'jsonrpc' => '2.0', + 'method' => 'getposts', + 'params' => [ + $limit, + [ + ['username' => $userNameRecipient], + ['username' => $userNameSender], + ] + ], + 'id' => time() + rand() + ] + ); + + if ($response = $this->_curl->execute()) { + + if ($response['error']) { + + $this->_error = _($response['error']['message']); + + } else { + + return $response['result']; // Array + } + } + + return false; + } + + public function follow(string $userName, array $userNames) { + + $this->_curl->prepare( + '/', + 'POST', + 30, + [ + 'jsonrpc' => '2.0', + 'method' => 'follow', + 'params' => [ + $userName, + $userNames + ], + 'id' => time() + rand() + ] + ); + + if ($response = $this->_curl->execute()) { + + if ($response['error']) { + + $this->_error = _($response['error']['message']); + + } else { + + return $response['result']; + } + } + + return false; + } + + public function getFollowing(string $userName) { + + $this->_curl->prepare( + '/', + 'POST', + 30, + [ + 'jsonrpc' => '2.0', + 'method' => 'getfollowing', + 'params' => [ + $userName + ], + 'id' => time() + rand() + ] + ); + + if ($response = $this->_curl->execute()) { + + if ($response['error']) { + + $this->_error = _($response['error']['message']); + + } else { + + return $response['result']; // Array usernames + } + } + + return false; + } + + public function getDHT(string $userName, string $command, string $flag) { + + $this->_curl->prepare( + '/', + 'POST', + 30, + [ + 'jsonrpc' => '2.0', + 'method' => 'dhtget', + 'params' => [ + $userName, + $command, + $flag + ], + 'id' => time() + rand() + ] + ); + + if ($response = $this->_curl->execute()) { + + if ($response['error']) { + + $this->_error = _($response['error']['message']); + + } else { + + return $response['result']; // Array + } + } + + return false; + } + public function createWalletUser(string $userName) { $this->_curl->prepare(