@ -8,6 +8,8 @@
require_once ( " include/oauth.php " );
require_once ( " include/html2plain.php " );
require_once ( " mod/share.php " );
require_once ( " include/Photo.php " );
/*
* Twitter - Like API
*
@ -822,6 +824,18 @@
$_REQUEST [ 'body' ] .= " \n \n " . $media ;
}
// To-Do: Multiple IDs
if ( requestdata ( 'media_ids' )) {
$r = q ( " SELECT `resource-id`, `scale`, `nickname`, `type` FROM `photo` INNER JOIN `user` ON `user`.`uid` = `photo`.`uid` WHERE `resource-id` IN (SELECT `resource-id` FROM `photo` WHERE `id` = %d) AND `scale` > 0 AND `photo`.`uid` = %d ORDER BY `photo`.`width` DESC LIMIT 1 " ,
intval ( requestdata ( 'media_ids' )), api_user ());
if ( $r ) {
$phototypes = Photo :: supportedTypes ();
$ext = $phototypes [ $r [ 0 ][ 'type' ]];
$_REQUEST [ 'body' ] .= " \n \n " . '[url=' . $a -> get_baseurl () . '/photos/' . $r [ 0 ][ 'nickname' ] . '/image/' . $r [ 0 ][ 'resource-id' ] . ']' ;
$_REQUEST [ 'body' ] .= '[img]' . $a -> get_baseurl () . " /photo/ " . $r [ 0 ][ 'resource-id' ] . " - " . $r [ 0 ][ 'scale' ] . " . " . $ext . " [/img][/url] " ;
}
}
// set this so that the item_post() function is quiet and doesn't redirect or emit json
$_REQUEST [ 'api_source' ] = true ;
@ -841,6 +855,41 @@
api_register_func ( 'api/statuses/update_with_media' , 'api_statuses_update' , true );
function api_media_upload ( & $a , $type ) {
if ( api_user () === false ) {
logger ( 'no user' );
return false ;
}
$user_info = api_get_user ( $a );
if ( ! x ( $_FILES , 'media' )) {
// Output error
return false ;
}
require_once ( 'mod/wall_upload.php' );
$media = wall_upload_post ( $a , false );
if ( ! $media ) {
// Output error
return false ;
}
$returndata = array ();
$returndata [ " media_id " ] = $media [ " id " ];
$returndata [ " media_id_string " ] = ( string ) $media [ " id " ];
$returndata [ " size " ] = $media [ " size " ];
$returndata [ " image " ] = array ( " w " => $media [ " width " ],
" h " => $media [ " height " ],
" image_type " => $media [ " type " ]);
logger ( " Media uploaded: " . print_r ( $returndata , true ), LOGGER_DEBUG );
return array ( " media " => $returndata );
}
api_register_func ( 'api/media/upload' , 'api_media_upload' , true );
function api_status_show ( & $a , $type ){
$user_info = api_get_user ( $a );
@ -1875,8 +1924,6 @@
if ( ! $ret )
return false ;
require_once ( " include/Photo.php " );
$attachments = array ();
foreach ( $images [ 1 ] AS $image ) {
@ -2002,7 +2049,6 @@
$start = iconv_strpos ( $text , $url , $offset , " UTF-8 " );
if ( ! ( $start === false )) {
require_once ( " include/Photo.php " );
$image = get_photo_info ( $url );
if ( $image ) {
// If image cache is activated, then use the following sizes: