laravel-urlscan maintained by xchimx
Description
This is a package for interaction with the Urlscan.io API
Author
Last update
2024/10/04 14:25
(dev-main)
License
Downloads
6
Tags
About Laravel-Urlscan
This is a package for interaction with the Urlscan.io API
Installation
You can install the package via composer:
composer require xchimx/laravel-urlscan
Add the Service Provider and Facade to your app.php config file if you're not using Package Discovery.
// config/app.php
'providers' => [
...
Xchimx\LaravelUrlScan\UrlScanServiceProvider::class,
...
];
'aliases' => [
...
'UrlScan' => Xchimx\LaravelUrlScan\UrlScan::class
...
];
Publish the config file using the artisan CLI tool:
php artisan vendor:publish --provider="Xchimx\LaravelUrlScan\UrlScanServiceProvider"
finally set the API Key in your ENV file:
URLSCAN_API="YOUR-API-KEY-SET-HERE"
Usage
make sure you import Urlscan
use Xchimx\LaravelUrlScan\UrlScan;
User
$user = UrlScan::user()->getQuotas();
Scan
$url = 'https://laravel.com/';
$visibility = 'public'; // Options: 'public', 'private', 'unlisted'
$result = UrlScan::scan()->submitUrl($url, $visibility);
Result
$uuid = '358c5c79-b712-4e61-b79e-4a59e3c8b116'; //laravel.com
$getResult = UrlScan::result()->getResult($uuid);
$getScreenshot = UrlScan::result()->getScreenshot($uuid);
Search
use any search terms from Urlscan Search Terms
$query = 'page.url.keyword:https\:\/\/www.paypal.com\/*';
$getSearchResults = UrlScan::search()->search($query);
Base combined example
public function startScan()
{
$url = 'https://laravel.com/';
$visibility = 'public'; // Options: 'public', 'private', 'unlisted'
$result = UrlScan::scan()->submitUrl($url, $visibility);
if (isset($result['uuid'])) {
sleep(10); //necessary else the scan isn't finished yet
$getResult = UrlScan::result()->getResult($result['uuid']);
$getScreenshot = UrlScan::result()->getScreenshot($result['uuid']);
return [
'result' => $getResult,
'screenhots' => $getScreenshot
];
} else {
return response()->json(['error' => 'UUID not found'], 400);
}
}