saveTo($image_path); // send picture to mastodon $app = new MastodonAPI($mastodon_config['access_token'], $mastodon_config['domain']); $curl_file = curl_file_create(realpath($image_path)); $body = ['file' => $curl_file]; $response = $app->uploadMedia($body); $file_id = $response->id; $statusText = 'Nouveau collage'; $status_data = [ 'status' => $statusText, 'visibility' => 'public', 'language' => 'fr', 'media_ids[]' => $file_id, ]; $app->postStatus($status_data); } catch (Exception $exception) { echo $exception->getMessage(); }