ВходПользовательПароль
   
Регистрация
Регистрация
Помощь
Помощь
Поиск
Поиск
Gosudar.com.ru  
  

Меню сайта
Навигация
Объявления Объявления
Блоги Блоги
Файловый архив Файловый архив
Последние Последние
Гостевая Гостевая
Контакты Контакты
Личный Раздел
Вход Вход
Регистрация Регистрация
Cms R3-born
Библиотека Библиотека
Файлы R3-born Файлы R3-born
Разработка(блог) Разработка(блог)
Демо-модули
Фотоальбом Фотоальбом
Новости Новости
Форум Форум

Счётчик
5643556435564355643556435
Главная » Библиотека

Библиотека

Библиотека  » CMS R3-born  » Документация
PHP 4 Using the Akismet class
Описание Manual. English
Автор martin Число Июль 14 2008, 10:06 Тип FAQ
Категория Документация
Просмотров 2372
Трекбек URL для этой записи: Трекбек
  Голосов 0


PHP 4 Using the Akismet class
Manual. English
The Akismet API documentation describes the low level interface. Its intended audience is authors of code such as the Akismet PHP4 class used in R3-born. As such, it contains some information you don't need to know or be concerned with, but it may help you understand what the Akismet class is doing.

Using the Class

The Akismet class takes care of all the connection and communications with the Akismet server and gives you a simpler high level interface.

Example 1, submitting a comment to be checked:

 Код:  
include 'class_akismet4.php';
   
// load array with comment data
$comment = array(
   'author'       => 'viagra-test-123',
   'email'        => 'test@example.com',
   'website'      => 'http://www.example.com/',
   'body'         => 'This is a test comment',
   'permalink'    => 'http://your-domain.com/path-to-your-comment-page',
   'user_ip'      => 'an-ip-address', // optional, if not in array defaults to $_SERVER['REMOTE_ADDR']
   'user_agent'   => 'user-agent-string', // optional, if not in array defaults to $_SERVER['HTTP_USER_AGENT']
);
   
// instantiate an instance of the class
$akismet = new Akismet('http://www.yourdomain.com/', 'YOUR_WORDPRESS_API_KEY', $comment);

// test for errors
if($akismet->errorsExist() { // returns true if any errors exist
   if($akismet->isError('AKISMET_INVALID_KEY')) {
      // do something
   } elseif($akismet->isError('AKISMET_RESPONSE_FAILED')) {
      // do something
   } elseif($akismet->isError('AKISMET_SERVER_NOT_FOUND')) {
      // do something
   }
} else {
   // No errors, check for spam
   if ($akismet->isSpam()) { // returns true if Akismet thinks the comment is spam
        // do something with the spam comment
   } else {
       // do something with the non-spam comment
   }
}


Example 2, submitting a mis-diagnosed comment:

You should incorporate the submitSpam() and submitHam() calls in your applications. Doing so helps Akisment improve its spam checking algorithms.

 Код:  
// load array with comment data
$comment = array(
   'author'       => 'viagra-test-123',
   'email'        => 'test@example.com',
   'website'      => 'http://www.example.com/',
   'body'         => 'This is a test comment',
   'permalink'    => 'http://your-domain.com/path-to-your-comment-page',
   'user_ip'      => 'an-ip-address', // optional, if not in array defaults to $_SERVER['REMOTE_ADDR']
   'user_agent'   => 'user-agent-string', // optional, if not in array defaults to $_SERVER['HTTP_USER_AGENT']
);

// instantiate an instance of the class
$akismet = new Akismet('http://www.yourdomain.com/', 'YOUR_WORDPRESS_API_KEY', $comment);

// submit the ham or spam comment
if (!$akismet->errorsExist()) {
   $akismet->submitHam();  // or submitSpam()
}


Additional methods

These methods, in additon to those shown above, are also available.

 Код:  
$akismet->getError($name); // return a specific error message from the errors array
$akismet->getErrors(); // return an array of all errors


References
 


Часовой пояс: GMT + 3

Кто онлайн
Кто онлайн
Кто онлайн Всего зарегистрированных пользователей: 405
Последний зарегистрированный пользователь: MugenEi
Сейчас посетителей на сайте: 54, из них зарегистрированных: 0, скрытых: 0, гостей: 47, ботов: 7
Больше всего посетителей (302) здесь было Июль 27 2023, 12:54
Зарегистрированные пользователи: нет
Боты : AhrefsBot (7)
Легенда: Админ, Зам.админа, ViP, Спамеры
Эти данные основаны на активности пользователей за последние пять минут

Вход
Вход
Пользователь:    Пароль:     Автоматически входить при каждом посещении     

Powered by R3-Born² © 2024
Все логотипы и торговые марки являются собственностью их законных владельцев.
Правила пользования | Полис Секретности

Valid XHTML 1.0 Transitional SPECIALIST® Online Certified PHP Specialist Valid CSS!