// preset
$type="json";
-
foreach ($API as $p=>$info){
if (strpos($a->query_string, $p)===0){
$called_api= explode("/",$p);
if($parent)
$_REQUEST['type'] = 'net-comment';
else {
+// logger("api_statuses_update: upload ".print_r($_FILES, true)." ".print_r($_POST, true)." ".print_r($_GET, true), LOGGER_DEBUG);
+//die("blubb");
$_REQUEST['type'] = 'wall';
if(x($_FILES,'media')) {
// upload the image if we have one
$in_reply_to_status_id_str = NULL;
$in_reply_to_user_id_str = NULL;
$in_reply_to_screen_name = NULL;
- if ($lastwall['parent']!=$lastwall['id']) {
+ if (intval($lastwall['parent']) != intval($lastwall['id'])) {
$in_reply_to_status_id= intval($lastwall['parent']);
$in_reply_to_status_id_str = (string) intval($lastwall['parent']);
}
}
+ // There seems to be situation, where both fields are identical:
+ // https://github.com/friendica/friendica/issues/1010
+ // This is a bugfix for that.
+ if (intval($in_reply_to_status_id) == intval($lastwall['id'])) {
+ logger('api_status_show: this message should never appear: id: '.$lastwall['id'].' similar to reply-to: '.$in_reply_to_status_id, LOGGER_DEBUG);
+ $in_reply_to_status_id = NULL;
+ $in_reply_to_user_id = NULL;
+ $in_reply_to_status_id_str = NULL;
+ $in_reply_to_user_id_str = NULL;
+ $in_reply_to_screen_name = NULL;
+ }
+
$status_info = array(
'text' => trim(html2plain(bbcode(api_clean_plain_items($lastwall['body']), false, false, 2, true), 0)),
'truncated' => false,
}
api_register_func('api/users/show','api_users_show');
+
+ function api_users_search(&$a, $type) {
+ $page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
+
+ $userlist = array();
+
+ if (isset($_GET["q"])) {
+ $r = q("SELECT id FROM unique_contacts WHERE name='%s'", dbesc($_GET["q"]));
+ if (!count($r))
+ $r = q("SELECT id FROM unique_contacts WHERE nick='%s'", dbesc($_GET["q"]));
+
+ if (count($r)) {
+ foreach ($r AS $user) {
+ $user_info = api_get_user($a, $user["id"]);
+ //echo print_r($user_info, true)."\n";
+ $userdata = api_apply_template("user", $type, array('user' => $user_info));
+ $userlist[] = $userdata["user"];
+ }
+ $userlist = array("users" => $userlist);
+ } else
+ die(api_error($a, $type, t("User not found.")));
+ } else
+ die(api_error($a, $type, t("User not found.")));
+
+ return ($userlist);
+ }
+
+ api_register_func('api/users/search','api_users_search');
+
/**
*
* http://developer.twitter.com/doc/get/statuses/home_timeline
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item`, `contact`
WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
- AND `contact`.`id` = `item`.`contact-id`
+ AND `contact`.`id` = `item`.`contact-id` AND `item`.`uid` = %d AND `item`.`verb` = '%s'
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
$sql_extra",
+ intval(api_user()),
+ dbesc(ACTIVITY_POST),
intval($id)
);
return $ret;
}
- function api_get_entitities($text, $bbcode) {
+ function api_get_entitities(&$text, $bbcode) {
/*
To-Do:
* Links at the first character of the post
- * different sizes of pictures
- * caching picture data (using the id for that?) (See privacy_image_cache)
*/
+ $a = get_app();
+
$include_entities = strtolower(x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:"false");
- if ($include_entities != "true")
+ if ($include_entities != "true") {
+ require_once("mod/proxy.php");
+
+ preg_match_all("/\[img](.*?)\[\/img\]/ism", $bbcode, $images);
+
+ foreach ($images[1] AS $image) {
+ $replace = proxy_url($image);
+ $text = str_replace($image, $replace, $text);
+ }
return array();
+ }
$bbcode = bb_CleanPictureLinks($bbcode);
$start = iconv_strpos($text, $url, $offset, "UTF-8");
if (!($start === false)) {
- $redirects = 0;
- $img_str = fetch_url($url,true, $redirects, 10);
- $image = @imagecreatefromstring($img_str);
+ require_once("include/Photo.php");
+ $image = get_photo_info($url);
if ($image) {
+ // If image cache is activated, then use the following sizes:
+ // thumb (150), small (340), medium (600) and large (1024)
+ if (!get_config("system", "proxy_disabled")) {
+ require_once("mod/proxy.php");
+ $media_url = proxy_url($url);
+
+ $sizes = array();
+ $scale = scale_image($image[0], $image[1], 150);
+ $sizes["thumb"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
+
+ if (($image[0] > 150) OR ($image[1] > 150)) {
+ $scale = scale_image($image[0], $image[1], 340);
+ $sizes["small"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
+ }
+
+ $scale = scale_image($image[0], $image[1], 600);
+ $sizes["medium"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
+
+ if (($image[0] > 600) OR ($image[1] > 600)) {
+ $scale = scale_image($image[0], $image[1], 1024);
+ $sizes["large"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
+ }
+ } else {
+ $media_url = $url;
+ $sizes["medium"] = array("w" => $image[0], "h" => $image[1], "resize" => "fit");
+ }
+
$entities["media"][] = array(
"id" => $start+1,
"id_str" => (string)$start+1,
"indices" => array($start, $start+strlen($url)),
- "media_url" => $url,
- "media_url_https" => $url,
+ "media_url" => normalise_link($media_url),
+ "media_url_https" => $media_url,
"url" => $url,
"display_url" => $display_url,
"expanded_url" => $url,
"type" => "photo",
- "sizes" => array("medium" => array(
- "w" => imagesx($image),
- "h" => imagesy($image),
- "resize" => "fit")));
+ "sizes" => $sizes);
}
$offset = $start + 1;
}
api_register_func('api/oauth/request_token', 'api_oauth_request_token', false);
api_register_func('api/oauth/access_token', 'api_oauth_access_token', false);
+
+ function api_fr_photos_list(&$a,$type) {
+ if (api_user()===false) return false;
+ $r = q("select distinct `resource-id` from photo where uid = %d and album != 'Contact Photos' ",
+ intval(local_user())
+ );
+ if($r) {
+ $ret = array();
+ foreach($r as $rr)
+ $ret[] = $rr['resource-id'];
+ header("Content-type: application/json");
+ echo json_encode($ret);
+ }
+ killme();
+ }
+
+ function api_fr_photo_detail(&$a,$type) {
+ if (api_user()===false) return false;
+ if(! $_REQUEST['photo_id']) return false;
+ $scale = ((array_key_exists('scale',$_REQUEST)) ? intval($_REQUEST['scale']) : 0);
+ $r = q("select * from photo where uid = %d and `resource-id` = '%s' and scale = %d limit 1",
+ intval(local_user()),
+ dbesc($_REQUEST['photo_id']),
+ intval($scale)
+ );
+ if($r) {
+ header("Content-type: application/json");
+ $r[0]['data'] = base64_encode($r[0]['data']);
+ echo json_encode($r[0]);
+ }
+
+ killme();
+ }
+
+ api_register_func('api/friendica/photos/list', 'api_fr_photos_list', true);
+ api_register_func('api/friendica/photo', 'api_fr_photo_detail', true);
+
+
+
+
+
+
function api_share_as_retweet($a, $uid, &$item) {
$body = trim($item["body"]);