<?php require dirname(__DIR__) . DIRECTORY_SEPARATOR . join(DIRECTORY_SEPARATOR, array("src", "Chatwork", "Autoloader.php")); Chatwork\Autoloader::register(); $token = getenv("CW_TOKEN"); $room_id = null; $message = ""; if (isset($_SERVER['argv'][1])) { $room_id = $_SERVER['argv'][1]; } if (isset($_SERVER['argv'][2])) { $message = $_SERVER['argv'][2]; } if (empty($token)) { die("please set CW_TOKEN\n"); } if (empty($room_id) || empty($message)) { die("# send_message.php\n# Usage:\n\nexport CW_TOKEN=************\nphp send_message.php <room_id> <message>\n"); } $client = \Chatwork\APIFactory::createInstance(array("token" => $token)); $client->sendMessage($room_id, $message);
$token = getenv("CW_TOKEN"); if (isset($_SERVER['argv'][1])) { $port = (int) $_SERVER['argv'][1]; } if (empty($token)) { die("please set CW_TOKEN\n"); } if (empty($port)) { $port = 8888; } if (is_file(".config")) { $config = json_decode(file_get_contents(".config"), true); } else { $config = array('MAX_QUEUE_COUNT' => 40, 'plugins' => array('\\Chatwork\\Server\\Plugin\\SendMessagePlugin'), 'providers' => array('\\Chatwork\\Server\\Provider\\SendMessageProvider', '\\Chatwork\\Server\\Provider\\StatisticsProvider', '\\Chatwork\\Server\\Provider\\FaviconProvider')); } $client = \Chatwork\APIFactory::createInstance(array("token" => $token, "plugins" => array('Chatwork\\Plugin\\Message\\SurroundInfoPlugin'))); $timer = uv_timer_init(); $loop = uv_default_loop(); $queue = new SplQueue(); $processor = new Chatwork\Server\QueueProcessor($loop, $timer, $queue); $stat = new \Chatwork\Server\Statistics(); $container = array("chatwork" => $client, "queue" => $queue, "config" => $config, "stat" => $stat); foreach ((array) $config['plugins'] as $plugin_class) { $plugin_klass = new $plugin_class($container); $processor->addPlugin($plugin_klass); unset($plugin_klass); } $kernel = new Chatwork\Server\Kernel(); $kernel->setRouter(new \Chatwork\Server\Router()); $kernel->setContainer($container); foreach ((array) $config['providers'] as $provider_class) {