Skip to content

This is a package for interaction with the Urlscan.io API

Notifications You must be signed in to change notification settings

xchimx/laravel-urlscan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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);
        }
    }

About

This is a package for interaction with the Urlscan.io API

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages