logger($e);
}
-
-
// workaround for HTTP-auth in CGI mode
if (x($_SERVER, 'REDIRECT_REMOTE_USER')) {
$userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)) ;
}
}
- if (!isset($_SERVER['PHP_AUTH_USER'])) {
+ if (!x($_SERVER, 'PHP_AUTH_USER')) {
logger('API_login: ' . print_r($_SERVER,true), LOGGER_DEBUG);
header('WWW-Authenticate: Basic realm="Friendica"');
throw new UnauthorizedException("This API requires login");
$called_api = explode("/", $p);
//unset($_SERVER['PHP_AUTH_USER']);
+
+ /// @TODO should be "true ==[=] $info['auth']", if you miss only one = character, you assign a variable (only with ==). Let's make all this even.
if ($info['auth'] === true && api_user() === false) {
api_login($a);
}
* get data from $_POST or $_GET
*/
function requestdata($k) {
- if (isset($_POST[$k])) {
+ if (x($_POST, $k)) {
return $_POST[$k];
}
- if (isset($_GET[$k])) {
+ if (x($_GET, $k)) {
return $_GET[$k];
}
return null;
unset($user_info["uid"]);
unset($user_info["self"]);
- return api_format_data("user", $type, array('user' => $user_info));
+ return api_format_data("user", $type, array('user' => $user_info));
}
break;
}
- return api_format_data("statuses", $type, $data);
+ return api_format_data("statuses", $type, $data);
}
/// @TODO move to top of file or somewhere better
return api_format_data("statuses", $type, $data);
} else {
$data = array('status' => $ret[0]);
- return api_format_data("status", $type, $data);
+ return api_format_data("status", $type, $data);
}
}
break;
}
- return api_format_data("statuses", $type, $data);
+ return api_format_data("statuses", $type, $data);
}
/// @TODO move to top of file or somwhere better
$data = api_rss_extra($a, $data, $user_info);
}
- return api_format_data("statuses", $type, $data);
+ return api_format_data("statuses", $type, $data);
}
/// @TODO move to top of file or somwhere better
list($status_user, $owner_user) = api_item_get_user($a,$item);
// Look if the posts are matching if they should be filtered by user id
- if ($filter_user AND ($status_user["id"] != $user_info["id"]))
+ if ($filter_user AND ($status_user["id"] != $user_info["id"])) {
continue;
+ }
$in_reply_to = api_in_reply_to($item);
$converted = api_convert_item($item);
- if ($type == "xml")
+ if ($type == "xml") {
$geo = "georss:point";
- else
+ } else {
$geo = "geo";
+ }
$status = array(
'text' => $converted["text"],
return false;
}
- if ($qtype == 'friends')
+ if ($qtype == 'friends') {
$sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
- if ($qtype == 'followers')
+ }
+ if ($qtype == 'followers') {
$sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND));
+ }
// friends and followers only for self
- if ($user_info['self'] == 0)
+ if ($user_info['self'] == 0) {
$sql_extra = " AND false ";
+ }
$r = q("SELECT `nurl` FROM `contact` WHERE `uid` = %d AND NOT `self` AND (NOT `blocked` OR `pending`) $sql_extra",
intval(api_user())
unset($user["uid"]);
unset($user["self"]);
- if ($user)
+ if ($user) {
$ret[] = $user;
+ }
}
return array('user' => $ret);
}
+
function api_statuses_friends($type) {
$data = api_statuses_f($type, "friends");
- if ($data===false) return false;
- return api_format_data("users", $type, $data);
+ if ($data === false) {
+ return false;
+ }
+ return api_format_data("users", $type, $data);
}
+
function api_statuses_followers($type) {
$data = api_statuses_f($type, "followers");
- if ($data===false) return false;
- return api_format_data("users", $type, $data);
+ if ($data === false) {
+ return false;
+ }
+ return api_format_data("users", $type, $data);
}
+
+ /// @TODO move to top of file or somewhere better
api_register_func('api/statuses/friends','api_statuses_friends',true);
api_register_func('api/statuses/followers','api_statuses_followers',true);
-
-
-
-
-
function api_statusnet_config($type) {
$a = get_app();
return api_format_data('config', $type, array('config' => $config));
}
+
+ /// @TODO move to top of file or somewhere better
api_register_func('api/gnusocial/config','api_statusnet_config', false);
api_register_func('api/statusnet/config','api_statusnet_config', false);
return api_format_data('version', $type, array('version' => $fake_statusnet_version));
}
+
+ /// @TODO move to top of file or somewhere better
api_register_func('api/gnusocial/version','api_statusnet_version', false);
api_register_func('api/statusnet/version','api_statusnet_version', false);
function api_friends_ids($type) {
return api_ff_ids($type,'friends');
}
+
function api_followers_ids($type) {
return api_ff_ids($type,'followers');
}
+ /// @TODO move to top of file or somewhere better
api_register_func('api/friends/ids','api_friends_ids',true);
api_register_func('api/followers/ids','api_followers_ids',true);
-
function api_direct_messages_new($type) {
$a = get_app();
$data = api_rss_extra($a, $data, $user_info);
}
- return api_format_data("direct-messages", $type, $data);
+ return api_format_data("direct-messages", $type, $data);
}
+ /// @TODO move to top of file or somewhere better
api_register_func('api/direct_messages/new','api_direct_messages_new',true, API_METHOD_POST);
/**
/// @todo return JSON data like Twitter API not yet implemented
}
- api_register_func('api/direct_messages/destroy', 'api_direct_messages_destroy', true, API_METHOD_DELETE);
+ /// @TODO move to top of file or somewhere better
+ api_register_func('api/direct_messages/destroy', 'api_direct_messages_destroy', true, API_METHOD_DELETE);
function api_direct_messages_box($type, $box, $verbose) {
$data = api_rss_extra($a, $data, $user_info);
}
- return api_format_data("direct-messages", $type, $data);
+ return api_format_data("direct-messages", $type, $data);
}
$verbose = (x($_GET, 'friendica_verbose') ? strtolower($_GET['friendica_verbose']) : "false");
return api_direct_messages_box($type, "sentbox", $verbose);
}
+
function api_direct_messages_inbox($type) {
$verbose = (x($_GET, 'friendica_verbose') ? strtolower($_GET['friendica_verbose']) : "false");
return api_direct_messages_box($type, "inbox", $verbose);
}
+
function api_direct_messages_all($type) {
$verbose = (x($_GET, 'friendica_verbose') ? strtolower($_GET['friendica_verbose']) : "false");
return api_direct_messages_box($type, "all", $verbose);
}
+
function api_direct_messages_conversation($type) {
$verbose = (x($_GET, 'friendica_verbose') ? strtolower($_GET['friendica_verbose']) : "false");
return api_direct_messages_box($type, "conversation", $verbose);
}
}
}
- return api_format_data("photos", $type, $data);
+ return api_format_data("photos", $type, $data);
}
function api_fr_photo_detail($type) {