xsist10/safebrowser

Client for the Google Safe Browser API

Installs: 26

Dependents: 0

Stars: 3

Watchers: 2

Open Issues: 1

Language: PHP

v1.0.1 2014-04-07 12:49 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
    }
}