xchimx / laravel-urlscan
This is a package for interaction with the Urlscan.io API
1.0.2
2024-10-04 12:25 UTC
Requires
- php: ^8.0|^8.1|^8.2|^8.3
- guzzlehttp/guzzle: ^7.0
- laravel/framework: ^9.0|^10.0|^11.0
README
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); } }