xsist10/safebrowser

This package is abandoned and no longer maintained. No replacement package was suggested.

Client for the Google Safe Browser API

v1.0.1 2014-04-07 12:49 UTC

This package is auto-updated.

Last update: 2023-11-18 17:55:07 UTC


README

Demo code for PHPSA14 (http://phpsouthafrica.com/) conference

Build Status Latest Stable Version Total Downloads License

Get an API key

Installing

This library is available via Composer:

{
    "require": {
        "xsist10/safebrowser": "v1.0.0"
    }
}

Using

<?php
require 'vendor/autoload.php';

use xsist10\SafeBrowsing\SafeBrowsing;
use xsist10\SafeBrowsing\Strategy\Chain;
use xsist10\SafeBrowsing\Strategy\Post;
use xsist10\SafeBrowsing\Strategy\Get;

$chain = new Chain();
$chain->append(new Post());
$chain->append(new Get());

$safeBrowsing = new SafeBrowsing("[API KEY]", $chain);
$response = $safeBrowsing->isUrlSafe('http://ianfette.org/');
if (!$response->isSecure()) {
    // Oh no! Panic!

    if ($response->hasMalware()) {
        // Malware detected
    }

    if ($response->hasPhishing()) {
        // Phising detected
    }
}