1. Installation of Msgpack, Yar, yaf three PHP extensions
2, compile Yar, use./configure--enable-msgpack--with-php-config=/usr/local/php/bin/pgp-config parameters,-- The Enable-msgpack parameter is to turn on packager support for Yar
3, Php-i|grep Msgpack, if there is Yar.packager = Msgpack = Msgpack The Yar has supported Msgpack
4. Test page
Class Yarcheckkeyword {
protected static $HOSTNAME = ' kwdt.yarc.service.weibo.com ';
protected static $PORT = ' 7002 ';
/**
*
* Request KWDT Server
*
* @param string $text text strings
*
* @param array $types keyword type
*
* @param int $return _text whether to return hit keyword 1. Yes 0. No, no, no, no.
*
* @return Array
*
*/
Public Function Connectkwdt_server ($text, $return _text = 1, $types =array (1, 2, 3), $withoutsass = False) {
if (!class_exists ("Yar_client") | |! $text | |! $types) {
Return "Yar_client no exists\n";
}
$funcname = "Detect";
$host = Yarcheckkeyword:: $HOSTNAME;
$port = Yarcheckkeyword:: $PORT;
try{
$client = new Yar_client ("tcp://$host: $port");
$response = $client $funcname ($text, $return _text, $types);
return $response;
}catch (Exception $e) {
Print_r ($e);
}
}
}
$text = ' aaaaaaaaaaa ';
$obj =new Yarcheckkeyword ();
$a = $obj->connectkwdt_server ($text);
Print_r ($a);
5, the above code saved as a file, using PHP execution, test results for the following description of success
Array
(
[0] =-1
[1] = no keyword occured
)
http://www.bkjia.com/PHPjc/760154.html www.bkjia.com true http://www.bkjia.com/PHPjc/760154.html techarticle 1, install Msgpack, Yar, yaf three PHP extension 2, compile Yar, use./configure--enable-msgpack--with-php-config=/usr/local/php/bin/ Pgp-config parameter,--enable-msgpack parameter ...