mirror of
https://github.com/xorgy/mediafire-fuse
synced 2026-01-13 13:14:29 -08:00
check and return mediafire response code for every api call
This commit is contained in:
@@ -59,12 +59,28 @@ static int _decode_user_get_info(mfhttp * conn, void *data)
|
||||
json_t *email;
|
||||
json_t *first_name;
|
||||
json_t *last_name;
|
||||
int retval;
|
||||
|
||||
if (data != NULL)
|
||||
return -1;
|
||||
|
||||
root = http_parse_buf_json(conn, 0, &error);
|
||||
|
||||
if (root == NULL) {
|
||||
fprintf(stderr, "http_parse_buf_json failed at line %d\n", error.line);
|
||||
fprintf(stderr, "error message: %s\n", error.text);
|
||||
return -1;
|
||||
}
|
||||
|
||||
node = json_object_by_path(root, "response");
|
||||
|
||||
retval = mfapi_check_response(node, "user/get_info");
|
||||
if (retval != 0) {
|
||||
fprintf(stderr, "invalid response\n");
|
||||
json_decref(root);
|
||||
return retval;
|
||||
}
|
||||
|
||||
node = json_object_by_path(root, "response/user_info");
|
||||
|
||||
email = json_object_get(node, "email");
|
||||
@@ -81,8 +97,7 @@ static int _decode_user_get_info(mfhttp * conn, void *data)
|
||||
|
||||
printf("\n\r");
|
||||
|
||||
if (root != NULL)
|
||||
json_decref(root);
|
||||
json_decref(root);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user