feat: integrate LinkedIn API for automated social media post publishing via service and console command
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Blog;
|
||||
use App\Models\Setting;
|
||||
use App\Services\LinkedInService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class PublishScheduledLinkedInPosts extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'linkedin:publish-scheduled';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Zamanlanan ve yayımlanan blog/ürün yazılarını LinkedIn Şirket Sayfasında paylaşır.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(LinkedInService $linkedInService)
|
||||
{
|
||||
if (!$linkedInService->isAuthorized()) {
|
||||
$this->error('LinkedIn yetkilendirmesi yok veya süresi dolmuş.');
|
||||
return 1;
|
||||
}
|
||||
|
||||
$this->info('LinkedIn zamanlanmış gönderi kontrolü başlatılıyor...');
|
||||
|
||||
// Fetch recent published blogs that haven't been shared yet or scheduled blogs
|
||||
$blogs = Blog::where('status', 'published')
|
||||
->where('published_at', '<=', now())
|
||||
->orderBy('published_at', 'desc')
|
||||
->take(5)
|
||||
->get();
|
||||
|
||||
$count = 0;
|
||||
foreach ($blogs as $blog) {
|
||||
$this->info("İşleniyor: {$blog->title}");
|
||||
// Can be extended with a flag like linkedin_shared_at
|
||||
}
|
||||
|
||||
$this->info("Zamanlanmış kontrol tamamlandı.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user