// virtual void LLBingTranslationHandler::getTranslateURL( std::string &url, const std::string &from_lang, const std::string &to_lang, const std::string &text) const { url = std::string("http://api.microsofttranslator.com/v2/Http.svc/Translate?appId=") + getAPIKey() + "&text=" + LLURI::escape(text) + "&to=" + to_lang; if (!from_lang.empty()) { url += "&from=" + from_lang; } }
// virtual void LLGoogleTranslationHandler::getTranslateURL( std::string &url, const std::string &from_lang, const std::string &to_lang, const std::string &text) const { url = std::string("https://www.googleapis.com/language/translate/v2?key=") + getAPIKey() + "&q=" + LLURI::escape(text) + "&target=" + to_lang; if (!from_lang.empty()) { url += "&source=" + from_lang; } }
// virtual bool LLGoogleTranslationHandler::isConfigured() const { return !getAPIKey().empty(); }
string Osu_Info::URL(MODE _mode, array<string, 8> _param) { string url = "https://osu.ppy.sh/api/"; // params are arranged in order as written in the wiki: https://github.com/peppy/osu-api/wiki switch (_mode) { /// \TODO: Smart checking for invalid values (undecided if to implement) case MODE::get_beatmaps: url += "get_beatmaps?"; if (_param[U32 PARAM::since] != "") url += ("since=" + _param[U32 PARAM::since] + "&"); if (_param[U32 PARAM::beatmapset_ID] != "") url += ("s=" + _param[U32 PARAM::beatmapset_ID] + "&"); if (_param[U32 PARAM::beatmap_ID] != "") url += ("b=" + _param[U32 PARAM::beatmap_ID] + "&"); if (_param[U32 PARAM::user_ID] != "") url += ("u=" + _param[U32 PARAM::user_ID] + "&"); if (_param[U32 PARAM::game_mode] != "") url += ("m=" + _param[U32 PARAM::game_mode] + "&"); if (_param[U32 PARAM::autoconverts] != "") url += ("a=" + _param[U32 PARAM::autoconverts] + "&"); if (_param[U32 PARAM::limit] != "") url += ("limit=" + _param[U32 PARAM::limit] + "&"); break; case MODE::get_user: url += "get_user?"; if (_param[U32 PARAM::user_ID] != "") url += ("u=" + _param[U32 PARAM::user_ID] + "&"); else { #ifdef _DEBUG cout << "ERROR: \"user_id\" required field is not specified for the \"get_user\" mode" << endl; system("PAUSE"); #endif return ""; } if (_param[U32 PARAM::game_mode] != "") url += ("m=" + _param[U32 PARAM::game_mode] + "&"); break; case MODE::get_scores: url += "get_scores?"; if (_param[U32 PARAM::beatmap_ID] != "") url += ("b=" + _param[U32 PARAM::beatmap_ID] + "&"); else { #ifdef _DEBUG cout << "ERROR: \"beatmap_id\" required field is not specified for the \"get_scores\" mode" << endl; system("PAUSE"); #endif return ""; } if (_param[U32 PARAM::user_ID] != "") url += ("u=" + _param[U32 PARAM::user_ID] + "&"); if (_param[U32 PARAM::game_mode] != "") url += ("m=" + _param[U32 PARAM::game_mode] + "&"); break; case MODE::get_user_best: url += "get_user_best?"; if (_param[U32 PARAM::user_ID] != "") url += ("u=" + _param[U32 PARAM::user_ID] + "&"); else { #ifdef _DEBUG cout << "ERROR: \"user_id\" required field is not specified for the \"get_user_best\" mode" << endl; system("PAUSE"); #endif return ""; } if (_param[U32 PARAM::game_mode] != "") url += ("m=" + _param[U32 PARAM::game_mode] + "&"); if (_param[U32 PARAM::limit] != "") url += ("limit=" + _param[U32 PARAM::limit] + "&"); break; case MODE::get_user_recent: url += "get_user_recent?"; if (_param[U32 PARAM::user_ID] != "") url += ("u=" + _param[U32 PARAM::user_ID] + "&"); else { #ifdef _DEBUG cout << "ERROR: \"user_id\" required field is not specified for the \"get_user_recent\" mode" << endl; system("PAUSE"); #endif return ""; } if (_param[U32 PARAM::game_mode] != "") url += ("m=" + _param[U32 PARAM::game_mode] + "&"); if (_param[U32 PARAM::limit] != "") url += ("limit=" + _param[U32 PARAM::limit] + "&"); break; case MODE::get_match: url += "get_match?"; if (_param[U32 PARAM::match_ID] != "") url += ("mp=" + _param[U32 PARAM::match_ID] + "&"); else { #ifdef _DEBUG cout << "ERROR: \"match_id\" required field is not specified for the \"get_match\" mode" << endl; system("PAUSE"); #endif return ""; } break; default: #ifdef _DEBUG cout << "ERROR: Illegal or unsupported mode specified!" << endl; system("PAUSE"); #endif return ""; }; url += ("k=" + getAPIKey()); // required; error otherwise return url; }