Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Enums\SocialAccount\Platform;
use App\Enums\SocialAccount\Status;
use App\Models\SocialAccount;
use App\Models\Workspace;
use App\Support\Timezone;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<SocialAccount>
*/
class SocialAccountFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'workspace_id' => Workspace::factory(),
'platform' => Platform::LinkedIn,
'platform_user_id' => $this->faker->uuid(),
'username' => $this->faker->userName(),
'display_name' => $this->faker->name(),
'access_token' => $this->faker->sha256(),
'refresh_token' => $this->faker->sha256(),
'token_expires_at' => now()->addDays(60),
'scopes' => [],
'meta' => [],
'status' => Status::Connected,
'timezone' => Timezone::DEFAULT,
];
}
public function linkedin(): static
{
return $this->state(fn (array $attributes) => [
'platform' => Platform::LinkedIn,
'scopes' => Platform::LinkedIn->requiredPublishScopes(),
]);
}
public function linkedinPage(): static
{
return $this->state(fn (array $attributes) => [
'platform' => Platform::LinkedInPage,
'scopes' => Platform::LinkedInPage->requiredPublishScopes(),
]);
}
public function x(): static
{
return $this->state(fn (array $attributes) => [
'platform' => Platform::X,
'scopes' => ['tweet.read', 'tweet.write', 'users.read', 'media.write', 'offline.access'],
]);
}
public function tiktok(): static
{
return $this->state(fn (array $attributes) => [
'platform' => Platform::TikTok,
'scopes' => ['user.info.basic', 'user.info.profile', 'user.info.stats', 'video.publish', 'video.upload', 'video.list'],
]);
}
public function youtube(): static
{
return $this->state(fn (array $attributes) => [
'platform' => Platform::YouTube,
'scopes' => [
'https://www.googleapis.com/auth/youtube.upload',
'https://www.googleapis.com/auth/youtube.readonly',
'https://www.googleapis.com/auth/youtube.force-ssl',
'https://www.googleapis.com/auth/yt-analytics.readonly',
],
]);
}
public function facebook(): static
{
return $this->state(fn (array $attributes) => [
'platform' => Platform::Facebook,
'scopes' => ['public_profile', 'pages_show_list', 'pages_read_engagement', 'pages_manage_posts', 'read_insights', 'business_management'],
]);
}
public function instagram(): static
{
return $this->state(fn (array $attributes) => [
'platform' => Platform::Instagram,
'scopes' => ['instagram_business_basic', 'instagram_business_content_publish', 'instagram_business_manage_insights'],
]);
}
public function threads(): static
{
return $this->state(fn (array $attributes) => [
'platform' => Platform::Threads,
'scopes' => ['threads_basic', 'threads_content_publish', 'threads_manage_insights'],
]);
}
public function pinterest(): static
{
return $this->state(fn (array $attributes) => [
'platform' => Platform::Pinterest,
'scopes' => ['boards:read', 'boards:write', 'pins:read', 'pins:write', 'user_accounts:read'],
]);
}
public function googleBusiness(): static
{
return $this->state(fn (array $attributes) => [
'platform' => Platform::GoogleBusiness,
'scopes' => Platform::GoogleBusiness->requiredPublishScopes(),
'meta' => [
'location_id' => 'accounts/123456789/locations/987654321',
'account_name' => 'accounts/123456789',
'location_name' => 'locations/987654321',
'google_user_id' => 'google-user-123',
],
]);
}
public function bluesky(): static
{
return $this->state(fn (array $attributes) => [
'platform' => Platform::Bluesky,
'scopes' => Platform::Bluesky->requiredPublishScopes(),
'token_expires_at' => now()->addHours(2),
'meta' => [
'service' => 'https://bsky.social',
'identifier' => '[email protected]',
'password' => encrypt('test-app-password'),
],
]);
}
public function mastodon(): static
{
return $this->state(fn (array $attributes) => [
'platform' => Platform::Mastodon,
'scopes' => Platform::Mastodon->requiredPublishScopes(),
'token_expires_at' => null, // Mastodon tokens don't expire
'meta' => [
'instance' => 'https://mastodon.social',
'client_id' => 'test-client-id',
'client_secret' => 'test-client-secret',
],
]);
}
public function telegram(): static
{
return $this->state(fn (array $attributes) => [
'platform' => Platform::Telegram,
'scopes' => Platform::Telegram->requiredPublishScopes(),
'token_expires_at' => null, // the shared bot token never expires
'access_token' => '',
'refresh_token' => '',
'username' => 'mychannel',
'meta' => [
'chat_id' => '-1001234567890',
'username' => 'mychannel',
'type' => 'channel',
],
]);
}
public function discord(): static
{
return $this->state(fn (array $attributes) => [
'platform' => Platform::Discord,
'scopes' => Platform::Discord->requiredPublishScopes(),
'token_expires_at' => null, // posting uses the global bot token
'access_token' => '',
'refresh_token' => '',
'platform_user_id' => '999000111', // guild id
'display_name' => 'My Server',
]);
}
public function disconnected(): static
{
return $this->state(fn (array $attributes) => [
'status' => Status::Disconnected,
'error_message' => 'Token expired',
'disconnected_at' => now(),
]);
}
public function tokenExpired(): static
{
return $this->state(fn (array $attributes) => [
'status' => Status::TokenExpired,
'token_expires_at' => now()->subDay(),
]);
}
}