Exemplo n.º 1
0
<?php

$searchUrl = 'http://nssug.baidu.com/su?&sugParams&prod=baike&ie=uft-8';
header('Content-Type: application/json');
if (!empty($_GET['wd'])) {
    // 判断是否为bae环境
    if (!preg_match('/baidu\\.com/', $_SERVER['HTTP_HOST'])) {
        $content = file_get_contents($searchUrl . '&wd=' . urlencode($_GET['wd']) . '&cb=' . urlencode($_GET['cb']));
        echo iconv('GB2312', 'UTF-8//IGNORE', $content);
    } else {
        require_once "../../../../bae_config.php";
        $httpproxy = BaeFetchUrl::getInstance(array('timeout' => 100000, 'conn_timeout' => 100000, 'max_response_size' => 102400));
        $res = $httpproxy->get($searchUrl . '&wd=' . urlencode($_GET['wd']) . '&cb=' . urlencode($_GET['cb']));
        echo iconv('GB2312', 'UTF-8//IGNORE', $httpproxy->body());
    }
}
Exemplo n.º 2
0
 public function getLogBySid($sid)
 {
     $params = array();
     $params['sid'] = $sid;
     $url = substr($this->server, 0, strrpos(trim($this->server), "/")) . "/debugbysid";
     if (defined(BAE_ENABLE) && BAE_ENABLE) {
         $httpproxy = BaeFetchUrl::getInstance(array('timeout' => 100000, 'conn_timeout' => 10000, 'max_response_size' => 512000));
         $ret = $httpproxy->post($url, $params);
         return $ret;
     }
     $ret = self::sendRequestByLocal($url, "post", $params);
     if (intval($ret['status']) === 0) {
         return $ret;
     } else {
         return false;
     }
 }