Bitcoin Forum
April 30, 2024, 06:03:15 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: WTB simple C++ code.  (Read 110 times)
tomaso88 (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
March 13, 2018, 10: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.
1714500195
Hero Member
*
Offline Offline

Posts: 1714500195

View Profile Personal Message (Offline)

Ignore
1714500195
Reply with quote  #2

1714500195
Report to moderator
1714500195
Hero Member
*
Offline Offline

Posts: 1714500195

View Profile Personal Message (Offline)

Ignore
1714500195
Reply with quote  #2

1714500195
Report to moderator
You get merit points when someone likes your post enough to give you some. And for every 2 merit points you receive, you can send 1 merit point to someone else!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714500195
Hero Member
*
Offline Offline

Posts: 1714500195

View Profile Personal Message (Offline)

Ignore
1714500195
Reply with quote  #2

1714500195
Report to moderator
deisik
Legendary
*
Offline Offline

Activity: 3444
Merit: 1280


English ⬄ Russian Translation Services


View Profile WWW
March 13, 2018, 06: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)?

starmyc
Full Member
***
Offline Offline

Activity: 198
Merit: 130

Some random software engineer


View Profile
March 15, 2018, 03:00:03 PM
 #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 <curl/curl.h>
#include <unistd.h>

#include <iostream>

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.

Hi, I'm just some random software engineer.
You can check my projects: Bitcoin & altcoin balances/addresses listing dumps: https://balances.crypto-nerdz.org/
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!