23 lines
659 B
C
23 lines
659 B
C
#include "lichess.h"
|
|
|
|
#include <string.h>
|
|
#include <json-c/json_tokener.h>
|
|
#include <stdio.h>
|
|
|
|
json_object* query_lichess(char* username)
|
|
{
|
|
/* This function queries the lichess api and returns a pointer to a
|
|
* json_object, that contains the profile of the queried player
|
|
*/
|
|
char* api_base = "https://lichess.org/api/user/";
|
|
char user_url[128];
|
|
strcpy(user_url,api_base);
|
|
strcat(user_url,username);
|
|
printf("%s",user_url);
|
|
char* http_response = request(user_url);
|
|
printf("\n%p\n",http_response);
|
|
json_object *lichessUser = json_tokener_parse(http_response);
|
|
json_object *profile = json_object_object_get(lichessUser,"profile");
|
|
return profile;
|
|
}
|