unset($user_info["uid"]);
unset($user_info["self"]);
- return ApiResponse::formatData("user", $type, ['user' => $user_info]);
+ return DI::apiResponse()->formatData("user", $type, ['user' => $user_info]);
}
/// @TODO move to top of file or somewhere better
Logger::info(API_LOG_PREFIX . 'End', ['action' => 'get_status', 'status_info' => $status_info]);
- return ApiResponse::formatData('statuses', $type, ['status' => $status_info]);
+ return DI::apiResponse()->formatData('statuses', $type, ['status' => $status_info]);
}
/**
unset($user_info['uid']);
unset($user_info['self']);
- return ApiResponse::formatData('user', $type, ['user' => $user_info]);
+ return DI::apiResponse()->formatData('user', $type, ['user' => $user_info]);
}
/// @TODO move to top of file or somewhere better
throw new BadRequestException('No search term specified.');
}
- return ApiResponse::formatData('users', $type, $userlist);
+ return DI::apiResponse()->formatData('users', $type, $userlist);
}
/// @TODO move to top of file or somewhere better
throw new NotFoundException;
}
- return ApiResponse::formatData("users", $type, ['users' => $users]);
+ return DI::apiResponse()->formatData("users", $type, ['users' => $users]);
}
/// @TODO move to top of file or somewhere better
DBA::close($tags);
if (empty($uriids)) {
- return ApiResponse::formatData('statuses', $type, $data);
+ return DI::apiResponse()->formatData('statuses', $type, $data);
}
$condition = ['uri-id' => $uriids];
bindComments($data['status']);
- return ApiResponse::formatData('statuses', $type, $data);
+ return DI::apiResponse()->formatData('statuses', $type, $data);
}
/// @TODO move to top of file or somewhere better
break;
}
- return ApiResponse::formatData("statuses", $type, $data);
+ return DI::apiResponse()->formatData("statuses", $type, $data);
}
break;
}
- return ApiResponse::formatData("statuses", $type, $data);
+ return DI::apiResponse()->formatData("statuses", $type, $data);
}
/// @TODO move to top of file or somewhere better
break;
}
- return ApiResponse::formatData("statuses", $type, $data);
+ return DI::apiResponse()->formatData("statuses", $type, $data);
}
/// @TODO move to top of file or somewhere better
if ($conversation) {
$data = ['status' => $ret];
- return ApiResponse::formatData("statuses", $type, $data);
+ return DI::apiResponse()->formatData("statuses", $type, $data);
} else {
$data = ['status' => $ret[0]];
- return ApiResponse::formatData("status", $type, $data);
+ return DI::apiResponse()->formatData("status", $type, $data);
}
}
$ret = api_format_items(Post::toArray($statuses), $user_info, false, $type);
$data = ['status' => $ret];
- return ApiResponse::formatData("statuses", $type, $data);
+ return DI::apiResponse()->formatData("statuses", $type, $data);
}
/// @TODO move to top of file or somewhere better
break;
}
- return ApiResponse::formatData("statuses", $type, $data);
+ return DI::apiResponse()->formatData("statuses", $type, $data);
}
/// @TODO move to top of file or somewhere better
break;
}
- return ApiResponse::formatData("statuses", $type, $data);
+ return DI::apiResponse()->formatData("statuses", $type, $data);
}
/// @TODO move to top of file or somewhere better
break;
}
- return ApiResponse::formatData("status", $type, $data);
+ return DI::apiResponse()->formatData("status", $type, $data);
}
/// @TODO move to top of file or somewhere better
break;
}
- return ApiResponse::formatData("statuses", $type, $data);
+ return DI::apiResponse()->formatData("statuses", $type, $data);
}
/// @TODO move to top of file or somewhere better
{
$ret = [];
/// @TODO $ret is not filled here?
- return ApiResponse::formatData('lists', $type, ["lists_list" => $ret]);
+ return DI::apiResponse()->formatData('lists', $type, ["lists_list" => $ret]);
}
/// @TODO move to top of file or somewhere better
'mode' => $mode
];
}
- return ApiResponse::formatData("lists", $type, ['lists' => ['lists' => $lists]]);
+ return DI::apiResponse()->formatData("lists", $type, ['lists' => ['lists' => $lists]]);
}
/// @TODO move to top of file or somewhere better
break;
}
- return ApiResponse::formatData("statuses", $type, $data);
+ return DI::apiResponse()->formatData("statuses", $type, $data);
}
/// @TODO move to top of file or somewhere better
if ($data === false) {
return false;
}
- return ApiResponse::formatData("users", $type, $data);
+ return DI::apiResponse()->formatData("users", $type, $data);
}
/**
if ($data === false) {
return false;
}
- return ApiResponse::formatData("users", $type, $data);
+ return DI::apiResponse()->formatData("users", $type, $data);
}
/// @TODO move to top of file or somewhere better
if ($data === false) {
return false;
}
- return ApiResponse::formatData("users", $type, $data);
+ return DI::apiResponse()->formatData("users", $type, $data);
}
/// @TODO move to top of file or somewhere better
$ids[] = $user['id'];
}
- return ApiResponse::formatData("ids", $type, ['id' => $ids]);
+ return DI::apiResponse()->formatData("ids", $type, ['id' => $ids]);
}
/// @TODO move to top of file or somewhere better
],
];
- return ApiResponse::formatData('config', $type, ['config' => $config]);
+ return DI::apiResponse()->formatData('config', $type, ['config' => $config]);
}
/// @TODO move to top of file or somewhere better
break;
}
- return ApiResponse::formatData("direct-messages", $type, $data);
+ return DI::apiResponse()->formatData("direct-messages", $type, $data);
}
/// @TODO move to top of file or somewhere better
// error if no id or parenturi specified (for clients posting parent-uri as well)
if ($verbose == "true" && ($id == 0 || $parenturi == "")) {
$answer = ['result' => 'error', 'message' => 'message id or parenturi not specified'];
- return ApiResponse::formatData("direct_messages_delete", $type, ['$result' => $answer]);
+ return DI::apiResponse()->formatData("direct_messages_delete", $type, ['$result' => $answer]);
}
// BadRequestException if no id specified (for clients using Twitter API)
if (!DBA::exists('mail', ["`uid` = ? AND `id` = ? " . $sql_extra, $uid, $id])) {
if ($verbose == "true") {
$answer = ['result' => 'error', 'message' => 'message id not in database'];
- return ApiResponse::formatData("direct_messages_delete", $type, ['$result' => $answer]);
+ return DI::apiResponse()->formatData("direct_messages_delete", $type, ['$result' => $answer]);
}
/// @todo BadRequestException ok for Twitter API clients?
throw new BadRequestException('message id not in database');
if ($result) {
// return success
$answer = ['result' => 'ok', 'message' => 'message deleted'];
- return ApiResponse::formatData("direct_message_delete", $type, ['$result' => $answer]);
+ return DI::apiResponse()->formatData("direct_message_delete", $type, ['$result' => $answer]);
} else {
$answer = ['result' => 'error', 'message' => 'unknown error'];
- return ApiResponse::formatData("direct_messages_delete", $type, ['$result' => $answer]);
+ return DI::apiResponse()->formatData("direct_messages_delete", $type, ['$result' => $answer]);
}
}
/// @todo return JSON data like Twitter API not yet implemented
// Set screen_name since Twidere requests it
$contact['screen_name'] = $contact['nick'];
- return ApiResponse::formatData('friendships-destroy', $type, ['user' => $contact]);
+ return DI::apiResponse()->formatData('friendships-destroy', $type, ['user' => $contact]);
}
api_register_func('api/friendships/destroy', 'api_friendships_destroy', true, API_METHOD_POST);
));
if ($verbose == "true" && !DBA::isResult($r)) {
$answer = ['result' => 'error', 'message' => 'no mails available'];
- return ApiResponse::formatData("direct_messages_all", $type, ['$result' => $answer]);
+ return DI::apiResponse()->formatData("direct_messages_all", $type, ['$result' => $answer]);
}
$ret = [];
break;
}
- return ApiResponse::formatData("direct-messages", $type, $data);
+ return DI::apiResponse()->formatData("direct-messages", $type, $data);
}
/**
}
}
}
- return ApiResponse::formatData("photos", $type, $data);
+ return DI::apiResponse()->formatData("photos", $type, $data);
}
/**
// return success of updating or error message
if (!is_null($data)) {
- return ApiResponse::formatData("photo_create", $type, $data);
+ return DI::apiResponse()->formatData("photo_create", $type, $data);
} else {
throw new InternalServerErrorException("unknown error - uploading photo failed, see Friendica log for more information");
}
$media = $_FILES['media'];
$data = save_media_to_database("photo", $media, $type, $album, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $desc, Photo::DEFAULT, $visibility, $photo_id);
if (!is_null($data)) {
- return ApiResponse::formatData("photo_update", $type, $data);
+ return DI::apiResponse()->formatData("photo_update", $type, $data);
}
}
// return success of updating or error message
if ($result) {
$answer = ['result' => 'updated', 'message' => 'Image id `' . $photo_id . '` has been updated.'];
- return ApiResponse::formatData("photo_update", $type, ['$result' => $answer]);
+ return DI::apiResponse()->formatData("photo_update", $type, ['$result' => $answer]);
} else {
if ($nothingtodo) {
$answer = ['result' => 'cancelled', 'message' => 'Nothing to update for image id `' . $photo_id . '`.'];
- return ApiResponse::formatData("photo_update", $type, ['$result' => $answer]);
+ return DI::apiResponse()->formatData("photo_update", $type, ['$result' => $answer]);
}
throw new InternalServerErrorException("unknown error - update photo entry in database failed");
}
// prepare json/xml output with data from database for the requested photo
$data = prepare_photo_data($type, $scale, $photo_id);
- return ApiResponse::formatData("photo_detail", $type, $data);
+ return DI::apiResponse()->formatData("photo_detail", $type, $data);
}
}
$grps[] = ['name' => $rr['name'], 'gid' => $rr['id'], $user_element => $users];
}
- return ApiResponse::formatData("groups", $type, ['group' => $grps]);
+ return DI::apiResponse()->formatData("groups", $type, ['group' => $grps]);
}
api_register_func('api/friendica/group_show', 'api_friendica_group_show', true);
if ($ret) {
// return success
$success = ['success' => $ret, 'gid' => $gid, 'name' => $name, 'status' => 'deleted', 'wrong users' => []];
- return ApiResponse::formatData("group_delete", $type, ['result' => $success]);
+ return DI::apiResponse()->formatData("group_delete", $type, ['result' => $success]);
} else {
throw new BadRequestException('other API error');
}
'user' => $user_info
];
- return ApiResponse::formatData("lists", $type, ['lists' => $list]);
+ return DI::apiResponse()->formatData("lists", $type, ['lists' => $list]);
}
}
$success = group_create($name, $uid, $users);
- return ApiResponse::formatData("group_create", $type, ['result' => $success]);
+ return DI::apiResponse()->formatData("group_create", $type, ['result' => $success]);
}
api_register_func('api/friendica/group_create', 'api_friendica_group_create', true, API_METHOD_POST);
'user' => $user_info
];
- return ApiResponse::formatData("lists", $type, ['lists' => $grp]);
+ return DI::apiResponse()->formatData("lists", $type, ['lists' => $grp]);
}
}
// return success message incl. missing users in array
$status = ($erroraddinguser ? "missing user" : "ok");
$success = ['success' => true, 'gid' => $gid, 'name' => $name, 'status' => $status, 'wrong users' => $errorusers];
- return ApiResponse::formatData("group_update", $type, ['result' => $success]);
+ return DI::apiResponse()->formatData("group_update", $type, ['result' => $success]);
}
api_register_func('api/friendica/group_update', 'api_friendica_group_update', true, API_METHOD_POST);
'user' => $user_info
];
- return ApiResponse::formatData("lists", $type, ['lists' => $list]);
+ return DI::apiResponse()->formatData("lists", $type, ['lists' => $list]);
}
}
// we found the item, return it to the user
$ret = api_format_items([$item], $user_info, false, $type);
$data = ['status' => $ret];
- return ApiResponse::formatData('status', $type, $data);
+ return DI::apiResponse()->formatData('status', $type, $data);
}
// the item can't be found, but we set the notification as seen, so we count this as a success
}
- return ApiResponse::formatData('result', $type, ['result' => 'success']);
+ return DI::apiResponse()->formatData('result', $type, ['result' => 'success']);
} catch (NotFoundException $e) {
throw new BadRequestException('Invalid argument', $e);
} catch (Exception $e) {
// error if no searchstring specified
if ($searchstring == "") {
$answer = ['result' => 'error', 'message' => 'searchstring not specified'];
- return ApiResponse::formatData("direct_messages_search", $type, ['$result' => $answer]);
+ return DI::apiResponse()->formatData("direct_messages_search", $type, ['$result' => $answer]);
}
// get data for the specified searchstring
$success = ['success' => true, 'search_results' => $ret];
}
- return ApiResponse::formatData("direct_message_search", $type, ['$result' => $success]);
+ return DI::apiResponse()->formatData("direct_message_search", $type, ['$result' => $success]);
}
/// @TODO move to top of file or somewhere better