{"id":265,"date":"2025-01-11T10:20:52","date_gmt":"2025-01-11T01:20:52","guid":{"rendered":"https:\/\/fumilymart.com\/?p=265"},"modified":"2025-01-22T10:50:05","modified_gmt":"2025-01-22T01:50:05","slug":"drogon-web-framework%e3%81%a7%e3%80%81gemini-api%e3%82%92%e7%aa%81%e3%81%8f","status":"publish","type":"post","link":"https:\/\/fumilymart.com\/?p=265","title":{"rendered":"Drogon Web Framework\u3067\u3001Gemini API\u3092\u7a81\u304f"},"content":{"rendered":"<p>Drogon Web Framework\u3068\u306f\u3001C++\u306eWeb\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u3002\u516c\u5f0f\u30b5\u30a4\u30c8\u306f\u3001https:\/\/drogon.org\/ \u3067\u3059\u3002\u30d3\u30eb\u30c9\u306e\u4ed5\u65b9\u3084Docker\u3067\u306e\u69cb\u7bc9\u65b9\u6cd5\u304c\u66f8\u304b\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u4e2d\u3067\u3001Gemini API\u3092\u7a81\u3044\u3066\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8868\u793a\u3059\u308b\u3060\u3051\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\u3002<br \/>\nGoogle Gemini API\u306b\u3064\u3044\u3066\u306f\u3001<br \/>\nhttps:\/\/aistudio.google.com \u304b\u3089\u3001API\u30ad\u30fc\u3092\u751f\u6210\u3057\u3066\u7d44\u307f\u8fbc\u307f\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n #include &lt;drogon\/drogon.h&gt;\n #include &lt;drogon\/utils\/Utilities.h&gt;\n #include &lt;trantor\/utils\/Logger.h&gt;\n \n ...\n \n Json::Value textJson;\n textJson[0][\"text\"] = text; \/\/ \u2190 'text'\u306f\u3054\u81ea\u7531\u306b\u3002\n Json::Value partsJson;\n partsJson[0][\"parts\"] = textJson;\n Json::Value requestJson;\n requestJson[\"contents\"] = partsJson;\n \n auto client = drogon::HttpClient::newHttpClient(\n     \"https:\/\/generativelanguage.googleapis.com\/\"\n );\n auto request = drogon::HttpRequest::newHttpJsonRequest(requestJson);\n std::string path = \"\/v1beta\/models\/\";\n request->setPath(path.append(\"gemini-1.5-flash\").append(\":generateContent\"));\n request->setPathEncode(false);\n request->setContentTypeCode(drogon::ContentType::CT_APPLICATION_JSON);\n request->setMethod(drogon::HttpMethod::Post);\n request->setParameter(\"key\", GEMINI_API_KEY); \/\/ \u2190Gemini API\u30ad\u30fc\n \n auto result = client->sendRequest(request, 60.0);\n if (result.first != drogon::ReqResult::Ok) {\n     LOG_ERROR << \"NG.\";\n }\n \n auto jsonObject = result.second->getJsonObject();\n if (jsonObject != nullptr) {\n     LOG_INFO << jsonObject->toStyledString();\n }\n<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Drogon Web Framework\u3068\u306f\u3001C++\u306eWeb\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u3002\u516c\u5f0f\u30b5\u30a4\u30c8\u306f\u3001https:\/\/drogon.org\/ \u3067\u3059\u3002\u30d3\u30eb\u30c9\u306e\u4ed5\u65b9\u3084Docker\u3067\u306e\u69cb\u7bc9\u65b9\u6cd5\u304c\u66f8\u304b\u308c\u3066\u3044\u307e\u3059\u3002 \u305d\u306e\u4e2d\u3067\u3001Gemini &#8230; <a title=\"Drogon Web Framework\u3067\u3001Gemini API\u3092\u7a81\u304f\" class=\"read-more\" href=\"https:\/\/fumilymart.com\/?p=265\" aria-label=\"Drogon Web Framework\u3067\u3001Gemini API\u3092\u7a81\u304f \u306b\u3064\u3044\u3066\u3055\u3089\u306b\u8aad\u3080\">\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-265","post","type-post","status-publish","format-standard","hentry","category-ict"],"_links":{"self":[{"href":"https:\/\/fumilymart.com\/index.php?rest_route=\/wp\/v2\/posts\/265","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fumilymart.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fumilymart.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fumilymart.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fumilymart.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=265"}],"version-history":[{"count":7,"href":"https:\/\/fumilymart.com\/index.php?rest_route=\/wp\/v2\/posts\/265\/revisions"}],"predecessor-version":[{"id":273,"href":"https:\/\/fumilymart.com\/index.php?rest_route=\/wp\/v2\/posts\/265\/revisions\/273"}],"wp:attachment":[{"href":"https:\/\/fumilymart.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fumilymart.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fumilymart.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}