Browse Source

Support for posting multiple pictures via API

tags/2019.09
Michael 2 months ago
parent
commit
ae3c9eceed
1 changed files with 14 additions and 12 deletions
  1. 14
    12
      include/api.php

+ 14
- 12
include/api.php View File

@@ -1157,19 +1157,21 @@ function api_statuses_update($type)
1157 1157
 		}
1158 1158
 	}
1159 1159
 
1160
-	// To-Do: Multiple IDs
1161 1160
 	if (requestdata('media_ids')) {
1162
-		$r = q(
1163
-			"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",
1164
-			intval(requestdata('media_ids')),
1165
-			api_user()
1166
-		);
1167
-		if (DBA::isResult($r)) {
1168
-			$phototypes = Image::supportedTypes();
1169
-			$ext = $phototypes[$r[0]['type']];
1170
-			$description = $r[0]['desc'] ?? '';
1171
-			$_REQUEST['body'] .= "\n\n" . '[url=' . System::baseUrl() . '/photos/' . $r[0]['nickname'] . '/image/' . $r[0]['resource-id'] . ']';
1172
-			$_REQUEST['body'] .= '[img=' . System::baseUrl() . '/photo/' . $r[0]['resource-id'] . '-' . $r[0]['scale'] . '.' . $ext . ']' . $description . '[/img][/url]';
1161
+		$ids = explode(',', requestdata('media_ids'));
1162
+		foreach ($ids as $id) {
1163
+			$r = q(
1164
+				"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",
1165
+				intval($id),
1166
+				api_user()
1167
+			);
1168
+			if (DBA::isResult($r)) {
1169
+				$phototypes = Image::supportedTypes();
1170
+				$ext = $phototypes[$r[0]['type']];
1171
+				$description = $r[0]['desc'] ?? '';
1172
+				$_REQUEST['body'] .= "\n\n" . '[url=' . System::baseUrl() . '/photos/' . $r[0]['nickname'] . '/image/' . $r[0]['resource-id'] . ']';
1173
+				$_REQUEST['body'] .= '[img=' . System::baseUrl() . '/photo/' . $r[0]['resource-id'] . '-' . $r[0]['scale'] . '.' . $ext . ']' . $description . '[/img][/url]';
1174
+			}
1173 1175
 		}
1174 1176
 	}
1175 1177
 

Loading…
Cancel
Save