1. Go to this page and download the library: Download phpgt/cli library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phpgt / cli example snippets
$app = new Application(
"Twitter example application",
new CliArgumentList(...$argv),
new TweetCommand(),
new ViewCommand(),
new FollowCommand(),
new DmCommand(),
new LoginCommand()
);
$app->run();
class TweetCommand extends Command {
public function __construct() {
$this->setName("tweet");
$this->setDescription("Send a Tweet to your timeline.");
$this->setRequiredParameter(true, "message", "m");
$this->setOptionalParameter(true, "location", "l");
}
public function run(ArgumentValueList $arguments):void {
if(!TwitterApi::isLoggedIn()) {
$this->writeLine("You must login first.", Stream::ERROR);
}
try {
$uri = TwitterApi::sendTweet($arguments->get("message"));
$this->writeLine("Sent! View online: $uri");
}
catch(TwitterApiException $exception) {
$this->writeLine(
"Error sending Tweet: "
. $exception->getMessage(),
Stream::ERROR
);
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.