<?php use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; //ライブラリを読み込む require_once __DIR__ . "/phpFlickr.php"; $app = new My1DayServer\Application(); $app['debug'] = true; $app->get('/messages', function () use($app) { $messages = $app->getAllMessages(); return $app->json($messages); }); $app->get('/messages/{id}', function ($id) use($app) { $message = $app->getMessage($id); return $app->json($message); }); $app->post('/messages', function (Request $request) use($app) { $data = $app->validateRequestAsJson($request); $username = isset($data['username']) ? $data['username'] : ''; $body = isset($data['body']) ? $data['body'] : ''; if (strcmp($username, 'image') == 0) { //Consumer Key $app_key = CONSUMER_KEY; //Consumer Secret $app_secret = CONSUMER_SECRET; //インスタンスを作成する $flickr = new phpFlickr($app_key, $app_secret); //検索ワードの指定 $keyword = $body; //取得件数の指定 $count = 1;
<?php use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; $app = new My1DayServer\Application(); $app['debug'] = true; $app->get('/messages', function () use($app) { $messages = $app->getAllMessages(); return $app->json($messages); }); $app->get('/messages/{id}', function ($id) use($app) { $message = $app->getMessage($id); return $app->json($message); }); $app->post('/messages', function (Request $request) use($app) { $data = $app->validateRequestAsJson($request); $username = isset($data['username']) ? $data['username'] : ''; $body = isset($data['body']) ? $data['body'] : ''; if ($body == "uranai") { $kekka = mt_rand(1, 6); if ($kekka == 1) { $kekka = "大吉"; } else { if ($kekka == 2) { $kekka = "吉"; } else { if ($kekka == 3) { $kekka = "中吉"; } else { if ($kekka == 4) { $kekka = "小吉";
<?php use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; $app = new My1DayServer\Application(); $app['debug'] = true; $app->get('/messages', function () use ($app) { $messages = $app->getAllMessages(); return $app->json($messages); }); $app->get('/messages/{id}', function ($id) use ($app) { $message = $app->getMessage($id); return $app->json($message); }); $app->post('/messages', function (Request $request) use ($app) { $data = $app->validateRequestAsJson($request); $username = isset($data['username']) ? $data['username'] : ''; $body = isset($data['body']) ? $data['body'] : ''; $createdMessage = $app->createMessage($username, $body, base64_encode(file_get_contents($app['icon_image_path']))); return $app->json($createdMessage); });
<?php use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; $app = new My1DayServer\Application(); $app['debug'] = true; $app->get('/messages', function () use ($app) { $messages = $app->getAllMessages(); return $app->json($messages); }); $app->get('/messages/{id}', function ($id) use ($app) { $message = $app->getMessage($id); return $app->json($message); }); $app->post('/messages', function (Request $request) use ($app) { $data = $app->validateRequestAsJson($request); $username = isset($data['username']) ? $data['username'] : ''; $body = isset($data['body']) ? $data['body'] : ''; //bodyの内容がuranaiだったら if(strcmp($body,'uranai') == 0){ //占い結果を擬似乱数で作成 $randint = rand(1,10); if($randint < 3){