https://bitcointalksearch.org/topic/m.4465984
I am working on 5 texts at the same time, so we can wait with clients
It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define NXTACCT 10154506025773104943LL
#define NXTSERVER "http://localhost:7874/nxt?requestType"
struct MemoryStruct { char *memory; size_t size; };
static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
{
size_t realsize = size * nmemb;
struct MemoryStruct *mem = (struct MemoryStruct *)data;
mem->memory = realloc(mem->memory, mem->size + realsize + 1);
if (mem->memory) {
memcpy(&(mem->memory[mem->size]), ptr, realsize);
mem->size += realsize;
mem->memory[mem->size] = 0;
}
return realsize;
}
char *issue_curl(char *arg)
{
CURL *curl_handle;
CURLcode res;
// from http://curl.haxx.se/libcurl/c/getinmemory.html
struct MemoryStruct chunk;
chunk.memory = malloc(1); // will be grown as needed by the realloc above
chunk.size = 0; // no data at this point
curl_global_init(CURL_GLOBAL_ALL); //init the curl session
curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle, CURLOPT_URL, arg); // specify URL to get
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); // send all data to this function
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk); // we pass our 'chunk' struct to the callback function
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0"); // some servers don't like requests that are made without a user-agent field, so we provide one
res = curl_easy_perform(curl_handle);
if ( res != CURLE_OK )
fprintf(stderr, "curl_easy_perform() failed: %s\n",curl_easy_strerror(res));
else
{
// printf("%lu bytes retrieved [%s]\n", (long)chunk.size,chunk.memory);
}
curl_easy_cleanup(curl_handle);
return(chunk.memory);
}
char *issue_getAccountBlockIds(int64_t acctid,int timestamp)
{
char cmd[512],*jsonstr;
sprintf(cmd,"%s=getAccountBlockIds&account=%llu×tamp=%d",NXTSERVER,acctid,timestamp);
jsonstr = issue_curl(cmd);
if ( jsonstr != 0 )
{
printf("getAccountBlockIds.%llu %s\n",acctid,jsonstr);
free(jsonstr);
}
return(0);
}
char *issue_getAccountPublicKey(int64_t acctid)
{
char cmd[512],*jsonstr;
sprintf(cmd,"%s=getAccountPublicKey&account=%llu",NXTSERVER,acctid);
jsonstr = issue_curl(cmd);
if ( jsonstr != 0 )
{
printf("getAccountPublicKey.%llu %s\n",acctid,jsonstr);
free(jsonstr);
}
return(0);
}
char *issue_getAccountTransactionIds(int64_t acctid,int timestamp)
{
char cmd[512],*jsonstr;
sprintf(cmd,"%s=getAccountTransactionIds&account=%llu×tamp=%d",NXTSERVER,acctid,timestamp);
jsonstr = issue_curl(cmd);
if ( jsonstr != 0 )
{
printf("getAccountTransactionIds.%llu %s\n",acctid,jsonstr);
free(jsonstr);
}
return(0);
}
char *issue_getBalance(int64_t acctid)
{
char cmd[512],*jsonstr;
sprintf(cmd,"%s=getBalance&account=%llu",NXTSERVER,acctid);
jsonstr = issue_curl(cmd);
if ( jsonstr != 0 )
{
printf("getBalance.%llu %s\n",acctid,jsonstr);
free(jsonstr);
}
return(0);
}
char *issue_getGuaranteedBalance(int64_t acctid,int numconfs)
{
char cmd[512],*jsonstr;
sprintf(cmd,"%s=getGuaranteedBalance&account=%llu&numberOfConfirmations=%d",NXTSERVER,acctid,numconfs);
jsonstr = issue_curl(cmd);
if ( jsonstr != 0 )
{
printf("getAccountTransactionIds.%llu %s\n",acctid,jsonstr);
free(jsonstr);
}
return(0);
}
char *issue_getAliasId(char *alias)
{
char cmd[512],*jsonstr;
sprintf(cmd,"%s=getAliasId&alias=%s",NXTSERVER,alias);
jsonstr = issue_curl(cmd);
if ( jsonstr != 0 )
{
printf("getAliasId.%s = %s\n",alias,jsonstr);
free(jsonstr);
}
return(0);
}
char *issue_getAliasIds(int64_t acctid,int timestamp)
{
char cmd[512],*jsonstr;
sprintf(cmd,"%s=getAliasIds&account=%llu×tamp=%d",NXTSERVER,acctid,timestamp);
jsonstr = issue_curl(cmd);
if ( jsonstr != 0 )
{
printf("getAliasIds.%llu %s\n",acctid,jsonstr);
free(jsonstr);
}
return(0);
}
char *issue_getAliasURI(char *alias)
{
char cmd[512],*jsonstr;
sprintf(cmd,"%s=getAliasURI&alias=%s",NXTSERVER,alias);
jsonstr = issue_curl(cmd);
if ( jsonstr != 0 )
{
printf("getAliasURI.%s = %s\n",alias,jsonstr);
free(jsonstr);
}
return(0);
}
char *issue_listAccountAliases(int64_t acctid)
{
char cmd[512],*jsonstr;
sprintf(cmd,"%s=listAccountAliases&account=%llu",NXTSERVER,acctid);
jsonstr = issue_curl(cmd);
if ( jsonstr != 0 )
{
printf("listAccountAliases.%llu %s\n",acctid,jsonstr);
free(jsonstr);
}
return(0);
}
int test_NXTAPI(int64_t acctid)
{
printf("test_NXTAPI(acctid: %llx %llu)\n",acctid,acctid);
issue_getAccountBlockIds(acctid,0);
issue_getAccountPublicKey(acctid);
issue_getAccountTransactionIds(acctid,0);
issue_getBalance(acctid);
issue_getGuaranteedBalance(acctid,15);
issue_getAliasId("NXTcommunityfund");
//issue_getAliasIds(acctid,0);
issue_getAliasURI("NXTcommunityfund");
issue_listAccountAliases(acctid);
return(0);
}
int main(int argc, const char * argv[])
{
test_NXTAPI(NXTACCT);
curl_global_cleanup();
}