Changes
This commit is contained in:
@@ -2,8 +2,16 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Jobs\CreateVkPost;
|
||||
use App\Services\VK\VkAuthService;
|
||||
use App\Services\VK\VkService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Inertia\Inertia;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use VK\Client\VKApiClient;
|
||||
use VK\OAuth\Scopes\VKOAuthUserScope;
|
||||
use VK\OAuth\VKOAuth;
|
||||
@@ -16,33 +24,43 @@ class VkPostController extends Controller
|
||||
|
||||
private VkService $vkService;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->vkService = new VkService(new VKApiClient());
|
||||
$this->wall_token = env('WALL_ACCESS_VK_TOKEN');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$oauth = new VKOAuth();
|
||||
$client_id = 52468445;
|
||||
$redirect_uri = 'https://crawdad-fresh-bream.ngrok-free.app/';
|
||||
$display = VKOAuthDisplay::PAGE;
|
||||
$scope = array(VKOAuthUserScope::WALL, VKOAuthUserScope::PHOTOS);
|
||||
$state = 'dJZ3N05uZc9jpcEgxD6y';
|
||||
$groups_ids = array(227826614);
|
||||
|
||||
$browser_url = $oauth->getAuthorizeUrl(VKOAuthResponseType::TOKEN, $client_id, $redirect_uri, $display, $scope, $state, $groups_ids);
|
||||
return redirect($browser_url);
|
||||
|
||||
}
|
||||
|
||||
public function wall()
|
||||
{
|
||||
return $this->vkService->createAlbum('Тестовый альбом');
|
||||
dd($this->vkService->getPostById(39));
|
||||
}
|
||||
|
||||
|
||||
public function getImages()
|
||||
{
|
||||
// Укажите путь к директории
|
||||
$directory = 'public/images';
|
||||
|
||||
// Получаем все файлы из директории
|
||||
$files = Storage::files($directory);
|
||||
|
||||
|
||||
// Фильтруем только изображения (например, jpg, png)
|
||||
$images = array_filter($files, function ($file) {
|
||||
return in_array(pathinfo($file, PATHINFO_EXTENSION), ['webp', 'jpeg', 'png', 'gif']);
|
||||
});
|
||||
|
||||
// Формируем полный URL для каждого изображения
|
||||
$imageUrls = array_map(function ($file) {
|
||||
return url(Storage::url($file)); // Добавляем домен
|
||||
}, $images);
|
||||
|
||||
return $imageUrls; // Возвращаем массив с полными URL изображений
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user