break;
}
} catch (\Exception $e) {
- echo 'Error: ' . $e->getMessage() . "\n";
+ Log::err('Error: ' . $e->getMessage());
exit(1);
}
}
list($redirect_uri, $socketStr) = $this->getHttpServerData();
$state = time();
- echo "To authenticate, open the following URL:\n"
+ Log::msg(
+ "To authenticate, open the following URL:\n"
. $this->getBrowserAuthUrl($host, $user, $redirect_uri, $state)
- . "\n";
+ );
$authParams = $this->startHttpServer($socketStr);
if ($authParams['state'] != $state) {
}
$this->cfg->hosts[$hostKey] = $host;
$this->cfg->save();
- echo "Server configuration $hostKey saved successfully.\n";
+ Log::info("Server configuration $hostKey saved successfully.");
}
protected function fetchAccessToken(
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);
}
}
}
$res = $req->send();
$postUrl = $res->getHeader('Location');
- echo "Post created at server\n";
- echo $postUrl . "\n";
+ Log::info('Post created at server');
+ Log::msg($postUrl);
}
}
?>
$res = $req->send();
$postUrl = $res->getHeader('Location');
- echo "Reply created at server\n";
- echo $postUrl . "\n";
+ Log::info('Reply created at server');
+ Log::msg($postUrl);
}
}
?>
public function run($verbose)
{
foreach ($this->cfg->hosts as $key => $host) {
- echo $key . "\n";
+ Log::msg($key);
if ($verbose) {
- echo ' URL: ' . $host->server . "\n";
- echo ' User: ' . $host->user . "\n";
+ Log::msg(' URL: ' . $host->server);
+ Log::msg(' User: ' . $host->user);
}
}
}
class Log
{
+ public static function info($msg)
+ {
+ echo $msg . "\n";
+ }
+
+ public static function msg($msg)
+ {
+ echo $msg . "\n";
+ }
+
public static function err($msg)
{
file_put_contents('php://stderr', $msg . "\n", FILE_APPEND);
$command .= ' ' . escapeshellarg((string) $this->req->getUrl());
- echo $command . "\n";
+ Log::msg($command);
}
}
\ No newline at end of file