You are here

function shurly_gsb in ShURLy 7

Same name and namespace in other branches
  1. 8 shurly.module \shurly_gsb()
1 call to shurly_gsb()
shurly_create_form_validate in ./shurly.module
Validation of the main form
2 string references to 'shurly_gsb'
shurly_create_form_validate in ./shurly.module
Validation of the main form
shurly_settings_form in ./shurly.admin.inc
Settings form

File

./shurly.module, line 1333
description http://www.youtube.com/watch?v=Qo7qoonzTCE

Code

function shurly_gsb($url) {
  $client = variable_get('shurly_gsb_config_client', NULL);
  $api_key = variable_get('shurly_gsb_apikey', NULL);
  $gsb_url = "https://safebrowsing.googleapis.com/v4/threatMatches:find?key=" . $api_key;
  $data = array(
    'client' => array(
      "clientId" => "lccx",
      "clientVersion" => "1.5.2",
    ),
    'threatInfo' => array(
      "threatTypes" => array(
        "MALWARE",
        "SOCIAL_ENGINEERING",
        "UNWANTED_SOFTWARE",
        "POTENTIALLY_HARMFUL_APPLICATION",
      ),
      "platformTypes" => array(
        "ALL_PLATFORMS",
      ),
      "threatEntryTypes" => array(
        "URL",
      ),
      "threatEntries" => array(
        array(
          "url" => $url,
        ),
      ),
    ),
  );
  $options = array(
    'headers' => array(
      'Content-Type' => 'application/json',
    ),
    'method' => 'POST',
    'data' => json_encode($data),
  );
  $request = drupal_http_request($gsb_url, $options);
  $reponse = json_decode($request->data);
  if ($reponse->matches) {
    return True;
  }
  else {
    return False;
  }
}