Não precisa de framework nem biblioteca externa — a extensão cURL, que já vem habilitada na maioria das instalações de PHP, é suficiente.
Função de requisição
function buscarPerfil(string $username): array
{
$ch = curl_init("https://scrapegram.cloud/api/v1/instagram/profile?username={$username}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . getenv('SCRAPEGRAM_TOKEN'),
]);
$resposta = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status !== 200) {
throw new RuntimeException("Erro HTTP {$status}");
}
return json_decode($resposta, true);
}
Usando em um Laravel existente
Se seu projeto já é Laravel, o helper Http:: deixa isso ainda mais simples:
$perfil = Http::withToken(config('services.scrapegram.token'))
->get('https://scrapegram.cloud/api/v1/instagram/profile', ['username' => 'nike'])
->json();
Mais exemplos prontos pra colar, endpoint por endpoint, estão na documentação interativa.