<?php
+/* To-Do:
+ - Detecting shared items and transfer them as retweeted items
+ - Automatically detect if incoming data is HTML or BBCode
+ - search for usernames should first search friendica, then the other open networks, then the closed ones
+*/
require_once("include/bbcode.php");
require_once("include/datetime.php");
require_once("include/conversation.php");
if (api_user()!==false) $extra_query .= "AND `contact`.`uid`=".intval(api_user());
}
- if (is_null($user) && $a->argc > (count($called_api)-1)){
+ if (is_null($user) AND ($a->argc > (count($called_api)-1)) AND (count($called_api) > 0)){
$argid = count($called_api);
list($user, $null) = explode(".",$a->argv[$argid]);
if(is_numeric($user)){
*/
function api_account_verify_credentials(&$a, $type){
if (api_user()===false) return false;
+
+ unset($_REQUEST["user_id"]);
+ unset($_GET["user_id"]);
+
$user_info = api_get_user($a);
// "verified" isn't used here in the standard
// - Adding last status
$user_info["status"] = api_status_show($a,"raw");
- unset($user_info["status"]["user"]);
+ if (!count($user_info["status"]))
+ unset($user_info["status"]);
+ else
+ unset($user_info["status"]["user"]);
// "cid", "uid" and "self" are only needed for some internal stuff, so remove it from here
unset($user_info["cid"]);
function api_statuses_home_timeline(&$a, $type){
if (api_user()===false) return false;
+ unset($_REQUEST["user_id"]);
+ unset($_GET["user_id"]);
+
$user_info = api_get_user($a);
// get last newtork messages
function api_statuses_mentions(&$a, $type){
if (api_user()===false) return false;
+ unset($_REQUEST["user_id"]);
+ unset($_GET["user_id"]);
+
$user_info = api_get_user($a);
// get last newtork messages
$start = $page*$count;
$sql_extra = '';
- if ($user_info['self']==1) $sql_extra .= " AND `item`.`wall` = 1 ";
+ if ($user_info['self']==1)
+ $sql_extra .= " AND `item`.`wall` = 1 ";
if ($exclude_replies > 0)
$sql_extra .= ' AND `item`.`parent` = `item`.`id`';
function api_favorites(&$a, $type){
+ global $called_api;
+
if (api_user()===false) return false;
+ $called_api= array();
+
$user_info = api_get_user($a);
+
// in friendica starred item are private
// return favorites only for self
logger('api_favorites: self:' . $user_info['self']);
$ret = array();
} else {
-
// params
$count = (x($_GET,'count')?$_GET['count']:20);
$page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
function api_direct_messages_new(&$a, $type) {
if (api_user()===false) return false;
- if (!x($_POST, "text") || !x($_POST,"screen_name")) return;
+ if (!x($_POST, "text") OR (!x($_POST,"screen_name") AND !x($_POST,"user_id"))) return;
$sender = api_get_user($a);
require_once("include/message.php");
- $r = q("SELECT `id`, `nurl` FROM `contact` WHERE `uid`=%d AND `nick`='%s'",
- intval(api_user()),
- dbesc($_POST['screen_name']));
+ if ($_POST['screen_name']) {
+ $r = q("SELECT `id`, `nurl` FROM `contact` WHERE `uid`=%d AND `nick`='%s'",
+ intval(api_user()),
+ dbesc($_POST['screen_name']));
+
+ $recipient = api_get_user($a, $r[0]['nurl']);
+ } else
+ $recipient = api_get_user($a, $_POST['user_id']);
- $recipient = api_get_user($a, $r[0]['nurl']);
$replyto = '';
$sub = '';
if (x($_REQUEST,'replyto')) {
}
}
- $id = send_message($recipient['id'], $_POST['text'], $sub, $replyto);
+ $id = send_message($recipient['cid'], $_POST['text'], $sub, $replyto);
if ($id>-1) {
$r = q("SELECT * FROM `mail` WHERE id=%d", intval($id));
function api_direct_messages_box(&$a, $type, $box) {
if (api_user()===false) return false;
+ unset($_REQUEST["user_id"]);
+ unset($_GET["user_id"]);
+
$user_info = api_get_user($a);
// params