Exemple #1
0
 public function get_by_api($ip)
 {
     $http = new HttpClient();
     $result = $http->get('http://ip.taobao.com/service/getIpInfo.php?ip=' . $ip);
     $res = json_decode($result, true);
     return $res['code'] == 0 ? $res['data'] : false;
 }
Exemple #2
0
function get_keywords($data, $number = 3)
{
    $data = trim(strip_tags($data));
    if (empty($data)) {
        return '';
    }
    if (strtolower(CHARSET) != 'utf-8') {
        $data = iconv('utf-8', CHARSET, $data);
    } else {
        $data = iconv('utf-8', 'gbk', $data);
    }
    $http = new HttpClient();
    $result = $http->post('http://tool.phpcms.cn/api/get_keywords.php', array('siteurl' => SITE_URL, 'charset' => CHARSET, 'data' => $data, 'number' => $number));
    if ($result) {
        if (strtolower(CHARSET) != 'utf-8') {
            return $result->getBody();
        } else {
            return iconv('gbk', 'utf-8', $result->getBody());
        }
    }
    return '';
}