Support for posting multiple pictures via API

This commit is contained in:
Michael 2019-08-06 05:34:04 +00:00
parent cbee91a61b
commit ae3c9eceed

View file

@ -1157,19 +1157,21 @@ function api_statuses_update($type)
} }
} }
// To-Do: Multiple IDs
if (requestdata('media_ids')) { if (requestdata('media_ids')) {
$r = q( $ids = explode(',', requestdata('media_ids'));
"SELECT `resource-id`, `scale`, `nickname`, `type`, `desc` 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", foreach ($ids as $id) {
intval(requestdata('media_ids')), $r = q(
api_user() "SELECT `resource-id`, `scale`, `nickname`, `type`, `desc` 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($id),
if (DBA::isResult($r)) { api_user()
$phototypes = Image::supportedTypes(); );
$ext = $phototypes[$r[0]['type']]; if (DBA::isResult($r)) {
$description = $r[0]['desc'] ?? ''; $phototypes = Image::supportedTypes();
$_REQUEST['body'] .= "\n\n" . '[url=' . System::baseUrl() . '/photos/' . $r[0]['nickname'] . '/image/' . $r[0]['resource-id'] . ']'; $ext = $phototypes[$r[0]['type']];
$_REQUEST['body'] .= '[img=' . System::baseUrl() . '/photo/' . $r[0]['resource-id'] . '-' . $r[0]['scale'] . '.' . $ext . ']' . $description . '[/img][/url]'; $description = $r[0]['desc'] ?? '';
$_REQUEST['body'] .= "\n\n" . '[url=' . System::baseUrl() . '/photos/' . $r[0]['nickname'] . '/image/' . $r[0]['resource-id'] . ']';
$_REQUEST['body'] .= '[img=' . System::baseUrl() . '/photo/' . $r[0]['resource-id'] . '-' . $r[0]['scale'] . '.' . $ext . ']' . $description . '[/img][/url]';
}
} }
} }