I'm looking for someone to program me a very simple code using acx.io api and send me the source code.
Requirements.
1. 1 file.
2. has to be in C++
3. All it has to do is print the price of btc every minute.
I will pay in BTC, ltc or eth. Please reply with your offers.
Hi,
Is C++ using curl is OK ?
If so:
#include
#include
using namespace std;
// url is https://acx.io/api/v2/tickers/btcaud.json
static size_t catch_body(void *buffer, size_t size, size_t nmemb, void *stream)
{
string s = string((char*)buffer);
string delim = "\"";
int idx = -1;
size_t pos = 0;
string token;
while ((pos = s.find(delim)) != string::npos) {
token = s.substr(0, pos);
if (token == "last")
idx = 0;
if (idx != -1)
idx ++;
if (idx == 3)
cout << token << endl;
s.erase(0, pos + delim.length());
}
return size * nmemb;
}
void run()
{
CURL *curl;
CURLcode res;
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if (!curl) {
cerr << "Could not initialize curl" << endl;
return;
}
curl_easy_setopt(curl, CURLOPT_URL, "https://acx.io/api/v2/tickers/btcaud.json");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, catch_body);
// curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
if (CURLE_OK != res) {
cerr << "Error while querying acx.io: " << res << endl;
}
curl_easy_cleanup(curl);
}
int main(void)
{
while(true) {
run();
sleep(60);
}
return 0;
}
Compile it & run it:
10806.78
10806.78
...
Don't forget to tip me !!!
Cheers.