/** * @see https://developers.facebook.com/docs/reference/api/user/ * @return basic informations about the account */ static FBAccountInfo *fb_get_account_info(FBContext *ctx) { JsonObject *obj = fb_query_get(ctx, "me", NULL); g_return_val_if_fail((obj != NULL), NULL); const gchar *user_name = json_object_get_string_member(obj, "username"); const gchar *user_id = json_object_get_string_member(obj, "id"); g_return_val_if_fail(user_name != NULL && user_id != NULL, NULL); FBAccountInfo *accountinfo = fb_account_info_init(); accountinfo->id = g_strdup(user_id); accountinfo->username = g_strdup(user_name); accountinfo->token = g_strdup(ctx->token); return accountinfo; }
static void load_account_info_fill(gchar *key, gchar *value, GSList **accountlist) { FBAccountInfo *info = fb_account_info_init(); info->id = g_strdup(key); JsonParser *parser = json_parser_new(); json_parser_load_from_data(parser, value, strlen(value), NULL); JsonNode *root = json_parser_get_root(parser); JsonObject *obj = json_node_get_object(root); info->token = g_strdup(json_object_get_string_member(obj, "token")); info->username = g_strdup(json_object_get_string_member(obj, "username")); *accountlist = g_slist_prepend(*accountlist, info); g_object_unref(parser); }