feat: integrate LinkedIn API for automated social media post publishing via service and console command

This commit is contained in:
Ümit Tunç
2026-08-07 23:43:38 +03:00
parent a51af8208d
commit 25cdfda897
11 changed files with 682 additions and 0 deletions
@@ -0,0 +1,54 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Services\LinkedInService;
use Illuminate\Http\Request;
class LinkedInController extends Controller
{
protected LinkedInService $linkedInService;
public function __construct(LinkedInService $linkedInService)
{
$this->linkedInService = $linkedInService;
}
/**
* Redirect admin to LinkedIn OAuth consent screen
*/
public function connect(Request $request)
{
$url = $this->linkedInService->getAuthorizationUrl();
return redirect()->away($url);
}
/**
* Handle OAuth Callback from LinkedIn
*/
public function callback(Request $request)
{
if ($request->has('error')) {
$errorDescription = $request->input('error_description', 'Yetkilendirme iptal edildi.');
return redirect('/admin/linked-in-settings')
->with('error', 'LinkedIn bağlantı hatası: ' . $errorDescription);
}
$code = $request->input('code');
if (!$code) {
return redirect('/admin/linked-in-settings')
->with('error', 'LinkedIn yetkilendirme kodu (code) alınamadı.');
}
$result = $this->linkedInService->handleCallback($code);
if ($result['success']) {
return redirect('/admin/linked-in-settings')
->with('success', $result['message']);
}
return redirect('/admin/linked-in-settings')
->with('error', $result['message']);
}
}