mirror of
https://github.com/twisterarmy/twister-php.git
synced 2025-02-06 20:04:15 +00:00
implement getPostK method
This commit is contained in:
parent
d05455f4d1
commit
c190ced542
@ -32,6 +32,7 @@ Currently not documented, please visit src/Client.php for details
|
|||||||
* getBlockHash
|
* getBlockHash
|
||||||
* getBlock
|
* getBlock
|
||||||
* getPosts
|
* getPosts
|
||||||
|
* getPostK
|
||||||
* follow
|
* follow
|
||||||
* unFollow
|
* unFollow
|
||||||
* getFollowing
|
* getFollowing
|
||||||
|
@ -332,7 +332,7 @@ class Client
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newPostMessage(string $userName, int $k, string $message, array &$errors = []): ?array
|
public function newPostMessage(string $userName, string $message, ?int $k = null, array &$errors = []): ?array
|
||||||
{
|
{
|
||||||
return $this->_exec(
|
return $this->_exec(
|
||||||
'/',
|
'/',
|
||||||
@ -343,7 +343,7 @@ class Client
|
|||||||
'params' =>
|
'params' =>
|
||||||
[
|
[
|
||||||
$userName,
|
$userName,
|
||||||
$k,
|
$this->getPostK($userName, $k),
|
||||||
$message
|
$message
|
||||||
],
|
],
|
||||||
'id' => time()
|
'id' => time()
|
||||||
@ -352,7 +352,7 @@ class Client
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newRetwistMessage(string $userName, int $k, string $sigUserPost, array $userPost, string $comment, array &$errors = []): ?array
|
public function newRetwistMessage(string $userName, string $sigUserPost, array $userPost, string $comment, ?int $k = null, array &$errors = []): ?array
|
||||||
{
|
{
|
||||||
return $this->_exec(
|
return $this->_exec(
|
||||||
'/',
|
'/',
|
||||||
@ -363,7 +363,7 @@ class Client
|
|||||||
'params' =>
|
'params' =>
|
||||||
[
|
[
|
||||||
$userName,
|
$userName,
|
||||||
$k,
|
$this->getPostK($userName, $k),
|
||||||
[
|
[
|
||||||
'sig_userpost' => $sigUserPost,
|
'sig_userpost' => $sigUserPost,
|
||||||
'userpost' => $userPost,
|
'userpost' => $userPost,
|
||||||
@ -375,4 +375,19 @@ class Client
|
|||||||
$errors
|
$errors
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPostK(string $userName, ?int $k = null): ?int
|
||||||
|
{
|
||||||
|
if (is_null($k))
|
||||||
|
{
|
||||||
|
if (null === $posts = $this->getPosts([$userName], 1))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isset($posts['result'][0]['userpost']['k']) ? (int) $posts['result'][0]['userpost']['k'] + 1 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $k;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user