Author

Topic: WTB simple C++ code. (Read 118 times)

full member
Activity: 198
Merit: 130
Some random software engineer
March 15, 2018, 10:00:03 AM
#3
Hi,

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:

Code:
#include
#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:

Code:
g++ -o go-acx go.cpp   -lcurl && ./go-acx
10806.78
10806.78
...

Don't forget to tip me !!!
Cheers.
legendary
Activity: 3514
Merit: 1280
English ⬄ Russian Translation Services
March 13, 2018, 01:59:08 PM
#2
Hi,

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.

What framework should be used (e.g. Qt, VS) or it should be a console only application? And which system is the code supposed to be run on (e.g. Windows, Linux)?
newbie
Activity: 22
Merit: 0
March 13, 2018, 05:46:25 AM
#1
Hi,

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.
Jump to: