git.cweiske.de
/
shpub.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add support for media endpoints
[shpub.git]
/
src
/
shpub
/
Command
/
Like.php
diff --git
a/src/shpub/Command/Like.php
b/src/shpub/Command/Like.php
index e7c6052fc6866b458b01a820f7dd7a03bdc845ad..ad19b8f529838a4014f50bc70420bff4eb1932b1 100644
(file)
--- a/
src/shpub/Command/Like.php
+++ b/
src/shpub/Command/Like.php
@@
-1,21
+1,12
@@
<?php
namespace shpub;
<?php
namespace shpub;
-class Command_Like
+class Command_Like
extends Command_AbstractProps
{
{
- /**
- * @var Config
- */
- protected $cfg;
-
- public function __construct($cfg)
- {
- $this->cfg = $cfg;
- }
-
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('like');
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('like');
+ static::optsGeneric($cmd);
$cmd->addArgument(
'url',
[
$cmd->addArgument(
'url',
[
@@
-25,30
+16,28
@@
class Command_Like
);
}
);
}
- public function run(
$command
)
+ public function run(
\Console_CommandLine_Result $cmdRes
)
{
{
- $url = Validator::url($c
ommand
->args['url'], 'url');
+ $url = Validator::url($c
mdRes
->args['url'], 'url');
if ($url === false) {
exit(10);
}
if ($url === false) {
exit(10);
}
- $body = http_build_query(
- [
- 'h' => 'entry',
- 'like-of' => $url,
- ]
- );
-
$req = new Request($this->cfg->host, $this->cfg);
$req = new Request($this->cfg->host, $this->cfg);
- $res = $req->send($body);
+ $req->setType('entry');
+ $req->addProperty('like-of', $url);
+
+ $this->handleGenericOptions($cmdRes, $req);
+ $res = $req->send();
+
$postUrl = $res->getHeader('Location');
if ($postUrl === null) {
Log::err('Error: Server sent no "Location" header and said:');
Log::err($res->getBody());
exit(20);
} else {
$postUrl = $res->getHeader('Location');
if ($postUrl === null) {
Log::err('Error: Server sent no "Location" header and said:');
Log::err($res->getBody());
exit(20);
} else {
-
echo "Like created at server\n"
;
-
echo $postUrl . "\n"
;
+
Log::info('Like created at server')
;
+
Log::msg($postUrl)
;
}
}
}
}
}
}