This is a package for interaction with the Urlscan.io API
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"
make sure you import Urlscan
use Xchimx\LaravelUrlScan\UrlScan;
$user = UrlScan::user()->getQuotas();
$url = 'https://laravel.com/';
$visibility = 'public'; // Options: 'public', 'private', 'unlisted'
$result = UrlScan::scan()->submitUrl($url, $visibility);
$uuid = '358c5c79-b712-4e61-b79e-4a59e3c8b116'; //laravel.com
$getResult = UrlScan::result()->getResult($uuid);
$getScreenshot = UrlScan::result()->getScreenshot($uuid);
use any search terms from Urlscan Search Terms
$query = 'page.url.keyword:https\:\/\/www.paypal.com\/*';
$getSearchResults = UrlScan::search()->search($query);
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);
}
}