You are here

function antispam_api_cmd_submit_spam in AntiSpam 7

Same name and namespace in other branches
  1. 6 antispam.module \antispam_api_cmd_submit_spam()

AntiSpam API: Submit Spam

Parameters

string $content_type: Content type; it can be 'node' or 'comment' .

object $content: Content object.

Return value

integer See constants ANTISPAM_API_RESULT_xxx.

1 call to antispam_api_cmd_submit_spam()
antispam_content_spam_operation in ./antispam.module
Mark content as spam or remove the mark.

File

./antispam.module, line 2225
Primary hook implementations for the Antispam module.

Code

function antispam_api_cmd_submit_spam($content_type, $content) {
  if (!variable_get('antispam_connection_enabled', 1)) {
    return ANTISPAM_API_RESULT_ERROR;
  }
  $provider = antispam_get_service_provider();
  $comment_data = antispam_prepare_comment_data($content_type, $content, $provider);
  $api_host = antispam_get_api_host($provider);
  $api_key = antispam_get_api_key($provider);
  if (empty($api_key)) {
    return ANTISPAM_API_RESULT_ERROR;
  }
  $query_string = _antispam_api_build_query_string($comment_data);
  $host = $api_key . '.' . $api_host;
  $response = _antispam_api_http_post($query_string, $host, '/' . ANTISPAM_AKISMET_API_VERSION . '/submit-spam');
  if (!isset($response[1])) {
    watchdog('antispam', "submitting spam: can not get a response back from the service provider " . antispam_get_provider_name($provider, FALSE));
    return ANTISPAM_API_RESULT_ERROR;
  }
  else {
    return ANTISPAM_API_RESULT_SUCCESS;
  }
}