Closed e1blue closed 10 months ago
I haven't tested it but you should be able to do something like the following for multiple images (I was lazy and only did two):
$response = $bluesky->request('POST', 'com.atproto.repo.uploadBlob', [], $image_file_content1, 'image/png');
$image1 = $response->blob;
$response = $bluesky->request('POST', 'com.atproto.repo.uploadBlob', [], $image_file_content2, 'image/png');
$image2 = $response->blob;
$args = [
'collection' => 'app.bsky.feed.post',
'repo' => $bluesky->getAccountDid(),
'record' => [
'text' => 'Testing with two images #TestingInProduction',
'langs' => ['en'],
'createdAt' => date('c'),
'$type' => 'app.bsky.feed.post',
'embed' => [
'$type' => 'app.bsky.embed.images',
'images' => [
[
'alt' => 'A test image',
'image' => $image1,
],
[
'alt' => 'A second test image',
'image' => $image2,
],
],
],
],
];
$response = $bluesky->request('POST', 'com.atproto.repo.createRecord', $args);```
I tried it, but I got Refresh Token Authentication Error: Syntax error. I'll think about it a little more myself. Thank you for your answer
I commented out $refresh_token = $bluesky->getRefreshToken(); etc. and was able to successfully submit multiple images. Thank you very much. It was very helpful.
I'm curious to see the code you were using to get the Refresh Token Authentication Error, as I've been unable to reproduce that. That said, if you're doing a single post of four images at an infrequent rate, you should be safe not using the refresh token.
Thank you for your confirmation & reply. It was very helpful.
Can I POST 4 images using this library?