function antispam_api_cmd_verify_key in AntiSpam 6
Same name and namespace in other branches
- 7 antispam.module \antispam_api_cmd_verify_key()
AntiSpam API: Key Verification
Parameters
string WordPress API Key.:
Return value
integer See constants ANTISPAM_API_RESULT_xxx.
1 call to antispam_api_cmd_verify_key()
- _antispam_settings_form in ./
antispam.admin.inc - Build the antispam settings form.
File
- ./
antispam.module, line 2010
Code
function antispam_api_cmd_verify_key($key) {
global $base_url;
if (empty($key)) {
return ANTISPAM_API_RESULT_ERROR;
}
$provider = antispam_get_service_provider();
$api_host = antispam_get_api_host($provider);
if ($provider == DEFENSIO_SERVICE) {
// DEFENSIO
$request = 'owner-url=' . $base_url . base_path();
$response = _antispam_api_http_post($request, $api_host, '/blog/' . DEFENSIO_API_VERSION . '/validate-key/' . $key . '.yaml');
if (!isset($response[1])) {
return ANTISPAM_API_RESULT_ERROR;
}
return _antispam_parse_yaml_response($response[1], 'status') == 'success' ? ANTISPAM_API_RESULT_SUCCESS : ANTISPAM_API_RESULT_ERROR;
}
else {
// AKISMET, TYPEPAD
$request = 'key=' . $key . '&blog=' . $base_url . base_path();
$response = _antispam_api_http_post($request, $api_host, '/' . AKISMET_API_VERSION . '/verify-key');
if (!isset($response[1])) {
return ANTISPAM_API_RESULT_ERROR;
}
return 'valid' == $response[1] ? ANTISPAM_API_RESULT_SUCCESS : ANTISPAM_API_RESULT_ERROR;
}
}