You are here

function antispam_api_cmd_spam_check in AntiSpam 6

Same name and namespace in other branches
  1. 7 antispam.module \antispam_api_cmd_spam_check()

AntiSpam API: Generic Data Check

return: -1 Error 0 Ham 1 Spam

File

./antispam.module, line 2045

Code

function antispam_api_cmd_spam_check($body, $name = NULL, $mail = NULL, $homepage = NULL) {
  $provider = antispam_get_service_provider();
  $api_host = antispam_get_api_host($provider);
  $api_key = antispam_get_api_key($provider);
  if (empty($api_key)) {
    return array(
      ANTISPAM_API_RESULT_ERROR,
    );
  }
  $content = array(
    'body' => $body,
    'name' => $name,
    'mail' => $mail,
    'homepage' => $homepage,
  );
  $api_result = antispam_api_cmd_comment_check('other', $content);
  if ($api_result[0] == ANTISPAM_API_RESULT_IS_HAM) {
    return 0;

    // Ham
  }
  else {
    if ($api_result[0] == ANTISPAM_API_RESULT_IS_SPAM) {
      return 1;

      // Spam
    }
    else {
      return -1;

      // Error
    }
  }
}