This PHP library provides a simple interface for generating images using the Midjourney Bot through the Discord API.
You can install this library using Composer. Run the following command in your project directory:
composer require ferranfg/midjourney-php
To generate an image using the Midjourney Bot, you first need to create an instance of the Midjourney
class:
use Ferranfg\MidjourneyPhp\Midjourney;
$midjourney = new Midjourney($discord_channel_id, $discord_user_token);
$message = $midjourney->generate('An astronaut riding a horse');
return $message->upscaled_photo_url;
-
$discord_channel_id
- Replaces this value with the Channel ID where the Midjourney Bot is installed. You can get the Channel ID right-clicking on the channel and Copy Channel ID.Remember that you can invite the Midjourney Bot to your own server to organize your work https://docs.midjourney.com/docs/invite-the-bot
-
$discord_user_token
- Automatic user accounts (self-bots) are not allowed by Discord and can result in an account termination if found, so use it at your own risk.To get your user token, visit https://discord.com/channels/@me and open the Network tab inside the Developers Tools. Find between your XHR requests the
Authorization
header.