스트리밍 API에서 각 트윗을 가져 와서 데이터베이스에 저장하는 프로그램을 C로 작성하려고합니다. 그러나 작동하지 않을 수 있습니다. 아래 코드를 사용하고 있습니다.libcurl 및 C로 Twitter Streaming API에 액세스
#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;
}
이 코드는 하나의 짹짹만 JSON 형식으로 출력합니다. 내가 도대체 뭘 잘못하고있는 겁니까? 덕분에
가능한 복제본 [Twitter Streaming API에 C 액세스] (http://stackoverflow.com/questions/4738002/accessing-the-twitter-streaming-api-with-c) – nmichaels