edited some pointer references

This commit is contained in:
max mustermann 2019-05-05 20:23:31 +02:00
parent 004ca7c62c
commit acd33bbbad
3 changed files with 8 additions and 9 deletions

View File

@ -3,14 +3,14 @@
// //
#include "API.h" #include "API.h"
#include "Hashmap.h"
#include <string> #include <string>
#include <iostream> #include <iostream>
#include "curl/curl.h"
#include <sstream> #include <sstream>
#include "Hashmap.h" #include <curl/curl.h>
std::string API::request(std::string myurl) { std::string API::request(std::string myurl) {
Hashmap<std::string,std::string> map; Hashmap<std::string,std::string> map;
@ -19,7 +19,7 @@ std::string API::request(std::string myurl) {
return request(myurl,false,map,str); return request(myurl,false,map,str);
} }
std::string API::request(std::string myurl, bool post, Hashmap<std::string,std::string> &map, std::vector<std::string> headers) { std::string API::request(std::string myurl, bool post, Hashmap<std::string,std::string> &map, std::vector<std::string> &headers) {
CURL *curl; CURL *curl;
CURLcode res; CURLcode res;
@ -52,7 +52,6 @@ std::string API::request(std::string myurl, bool post, Hashmap<std::string,std::
} }
poststring << "}"; poststring << "}";
// std::cout << "post string: " << poststring.str() << "\n";
curl_easy_setopt(curl, CURLOPT_POST, 1); curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, poststring.str().c_str()); curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, poststring.str().c_str());
}else{ }else{

View File

@ -12,7 +12,7 @@
class API { class API {
public: public:
std::string request(std::string myurl); std::string request(std::string myurl);
std::string request(std::string myurl, bool post, Hashmap<std::string,std::string> &map,std::vector<std::string> headers); std::string request(std::string myurl, bool post, Hashmap<std::string,std::string> &map,std::vector<std::string> &headers);
private: private:
static size_t write_data(void *buffer, size_t size, size_t buffersize, FILE *stream); static size_t write_data(void *buffer, size_t size, size_t buffersize, FILE *stream);

View File

@ -21,9 +21,9 @@ int main() {
if(oldip == ip){ if(oldip == ip){
std::cout << "no change -- ip: " << ip << std::endl; std::cout << "no change -- ip: " << ip << std::endl;
logger.logToLogfile("no change -- ip: "+ip); logger.logToLogfile(" [INFO] no change -- ip: "+ip);
} else{ } else{
logger.logToLogfile("ip changed! -- from :" + oldip + "to: "+ip); logger.logToLogfile(" [INFO] ip changed! -- from :" + oldip + "to: "+ip);
std::cout << "ip changed! -- from :" << oldip << "to: " << ip << std::endl; std::cout << "ip changed! -- from :" << oldip << "to: " << ip << std::endl;
//api key: 88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg //api key: 88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg
@ -40,7 +40,7 @@ int main() {
std::string dynurepl = api.request("https://api.dynu.com/v2/dns/8506047",true, args,headers); std::string dynurepl = api.request("https://api.dynu.com/v2/dns/8506047",true, args,headers);
std::cout << "---" << dynurepl << std::endl; std::cout << "[ DEBUG ] api reply:: " << dynurepl << std::endl;
if (dynurepl != "{\"statusCode\":200}"){ if (dynurepl != "{\"statusCode\":200}"){
logger.logToLogfile(" [ERROR] failed to write ip to dynu api!"); logger.logToLogfile(" [ERROR] failed to write ip to dynu api!");