xsist10/haveibeenpwned

Client for the "Have I Been Pwned" API

1.1.1 2017-07-29 18:49 UTC

README

Build Status

Install

{
    "require": {
        "xsist10/haveibeenpwned": "~1.0"
    }
}

Usage

Create manager instance

use xsist10\HaveIBeenPwned\HaveIBeenPwned;
use xsist10\HaveIBeenPwned\Adapter\Curl;
use xsist10\HaveIBeenPwned\Adapter\FileGetContents;

// By default the $manager will use a Curl adapter
$manager = new HaveIBeenPwned();

// You can create a new manager with a specified adapter
$manager = new HaveIBeenPwned(new Curl());

// You can also set the adapter after creation
$manager->setAdapter(new FileGetContents());

Check if you've been pwned

use xsist10\HaveIBeenPwned\HaveIBeenPwned;

$manager = new HaveIBeenPwned();
$manager->checkAccount("your_email_address");

Check if your account has been leaked in a paste

use xsist10\HaveIBeenPwned\HaveIBeenPwned;

$manager = new HaveIBeenPwned();
$manager->getPasteAccount("your_email_address");

List all breaches that have are on record

use xsist10\HaveIBeenPwned\HaveIBeenPwned;

$manager = new HaveIBeenPwned();
$manager->getBreaches();

$manager->getBreach('specific_breach_by_name');

List the types of data that are covered when describing a leak

use xsist10\HaveIBeenPwned\HaveIBeenPwned;

$manager = new HaveIBeenPwned();
$manager->getDataClasses();

Logger Support

The adapters support PSR-3 Logger. I recommend using monolog.

Install Monolog

$ composer require monolog/monolog

Use Monolog with HaveIBeenPwned

use xsist10\HaveIBeenPwned\HaveIBeenPwned;
use xsist10\HaveIBeenPwned\Adapter\Curl;

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$log = new Logger('name');
// Push all logging up to the level of DEBUG to our log file
$log->pushHandler(new StreamHandler('[full log filename]', Logger::DEBUG));

$adapter = new Curl();
$adapter->setLogger($log);
$manager = new HaveIBeenPwned($adapter);

// Calls made to HaveIBeenPwned will be logged to your log file now

Credits

License

The MIT License (MIT). Please see License File for more information.