kopia lustrzana https://gitlab.com/tomaszg/geostat
Include link to user profile in HTML output
rodzic
b45b329003
commit
e3087f3695
|
@ -150,6 +150,12 @@ int main(int argc, char** argv) {
|
|||
std::string ocnl_user;
|
||||
std::string ocro_user;
|
||||
std::string ocuk_user;
|
||||
std::string ocpl_user_profile;
|
||||
std::string ocde_user_profile;
|
||||
std::string ocus_user_profile;
|
||||
std::string ocnl_user_profile;
|
||||
std::string ocro_user_profile;
|
||||
std::string ocuk_user_profile;
|
||||
std::string ocpl_url = "https://opencaching.pl/okapi/";
|
||||
std::string ocde_url = "https://www.opencaching.de/okapi/";
|
||||
std::string ocus_url = "http://www.opencaching.us/okapi/";
|
||||
|
@ -278,6 +284,7 @@ int main(int argc, char** argv) {
|
|||
Okapi OCpl(ocpl_url, ocpl_key);
|
||||
if (!ocpl_user.empty()) ocpl_user_uuid = OCpl.get_uuid(ocpl_user);
|
||||
cc.merge(OCpl.get_user_caches(ocpl_user_uuid, 0));
|
||||
ocpl_user_profile = OCpl.get_profile_url(ocpl_user_uuid);
|
||||
}
|
||||
if (!ocde_user_uuid.empty() || !ocde_user.empty()) {
|
||||
Okapi OCde(ocde_url, ocde_key);
|
||||
|
@ -341,7 +348,7 @@ int main(int argc, char** argv) {
|
|||
std::cout << " <title>Geocaching stats</title>\n";
|
||||
std::cout << "</head>\n";
|
||||
std::cout << "<body>\n";
|
||||
std::cout << "<h1>Geocaching stats for user " << ocpl_user << "</h1>\n";
|
||||
std::cout << "<h1>Geocaching stats for user <a href=\"" << ocpl_user_profile << "\">" << ocpl_user << "</a></h1>\n";
|
||||
}
|
||||
|
||||
if (!heat_file.empty()) {
|
||||
|
|
|
@ -15,6 +15,7 @@ static const std::string OKAPI_logs = "services/logs/userlogs";
|
|||
static const std::string OKAPI_cache = "services/caches/geocache";
|
||||
static const std::string OKAPI_caches = "services/caches/geocaches";
|
||||
static const std::string OKAPI_username = "services/users/by_username";
|
||||
static const std::string OKAPI_user = "services/users/user";
|
||||
static const std::string OKAPI_changelog = "services/replicate/changelog";
|
||||
|
||||
// Callback for cURL easy interface used to save received output to std::string object
|
||||
|
@ -201,6 +202,13 @@ std::string Okapi::get_uuid(std::string username) {
|
|||
return j["uuid"];
|
||||
}
|
||||
|
||||
std::string Okapi::get_profile_url(std::string uuid) {
|
||||
std::string service = url + OKAPI_user;
|
||||
std::string query = "consumer_key=" + key + "&user_uuid=" + uuid + "&fields=profile_url";
|
||||
json j = json::parse(curl_post(service, query));
|
||||
return j["profile_url"];
|
||||
}
|
||||
|
||||
std::string Okapi::get_changelog_json(int revision) {
|
||||
std::string service = url + OKAPI_changelog;
|
||||
std::string query = "consumer_key=" + key + "&since=" + std::to_string(revision);
|
||||
|
|
1
okapi.h
1
okapi.h
|
@ -26,4 +26,5 @@ public:
|
|||
std::string get_changelog_json(int revision);
|
||||
|
||||
std::string get_uuid(std::string username);
|
||||
std::string get_profile_url(std::string uuid);
|
||||
};
|
||||
|
|
Ładowanie…
Reference in New Issue