'getPosts', 2 => 'writePost', 3 => 'getFriends' ); public $name; public $key; function __construct($name, $key) { $this->name = $name; $this->key = $key; $this->user = new Me2AuthenticatedUser($this->name, $this->key); } function getPosts() { echo "글을 가져와야 해요.\n"; } function writePost() { echo "글을 작성해야 해요.\n"; } function getFriends() { echo "친구 목록을 가져와야 해요.\n"; } function usage() { echo str_repeat('=', 8)."\n"; echo "1. 최근글 가져오기\n"; echo "2. 글 작성\n"; echo "3. 친구 보기\n"; echo "4. 그만 하기\n"; echo str_repeat('=', 8)."\n>> "; } function start() { $methodMap = self::$methodMap; $this->usage(); while($method = fgets(STDIN)) if($method != 4) { settype($method, 'integer'); if(isset($methodMap[$method])) $this->{$methodMap[$method]}(); $this->usage(); } else break; } } Me2API::$applicationKey = '828e442ceea1ecdbc7db09d644ae69e9'; while(true) { echo 'me2day id: '; $name = trim(fgets(STDIN)); echo 'me2day api_key: '; $api_key = trim(fgets(STDIN)); echo "\n\n"; try { $console = new Me2Expo($name, $api_key); break; } catch(Me2UnauthenticatedException $e) { echo "잘못된 사용자 이름 혹은 키입니다. 다시 입력하세요.\n\n"; continue; } } $console->start();