I'm trying to write a program in C which will take each tweet from the streaming API and store it in a database. However, I can't get it to work, I'm using the below code:
#include <stdio.h>
#include <curl/curl.h>
#include <stdlib.h>
size_t callback_func(void *ptr, size_t size, size_t count, void *stream) {
/* ptr - your string variable.
stream - data chuck you received */
printf("res %s \n \n", (char*)ptr); //prints chunck of data for each call.
}
int main(void)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://google.com/");
//curl_easy_setopt(curl, CURLOPT_USERPWD, "JEggers2:password");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, callback_func);
curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}
This code only outputs one tweet in JSON format. What am I doing wrong? thanks