Suggest.php 552 Bytes
<?php 

/**
 * 搜索提示
 * @author tongdesheng
 *
 */
class YHMSearch_Suggest extends YHMSearch_Core {
	
	private $_urlPath = 'suggest';
	
	public function getSuggest($keyword, $size=5) {
		$params = array(
			'keyword' => $keyword,
			'size' => $size
		);
		$retData = $this->req($this->_urlPath, $params);
		//{"suggest":{"items":[{"item":"iphone5case彩","frequency":1},{"item":"iphone5","frequency":1},{"item":"iphone5case","frequency":1}]}}
		if(!empty($retData['suggest'])) {
			return $retData['suggest']['items'];
		}
		return array();
	}
}