Exemplo n.º 1
0
 private function getContentByUrl($url)
 {
     $target = new HttpLib();
     $ret = $target->get($url);
     if ($ret['response']['code'] == 200) {
         return $ret['body'];
     }
     return false;
 }
Exemplo n.º 2
0
 public static function send($path, $data = [], $method = "GET")
 {
     $request_url = self::$url . $path;
     $http = new HttpLib();
     if ($method == "POST") {
         $res = $http->post($request_url, $data);
     } else {
         $res = $http->get($request_url, []);
     }
     return $res['body'];
 }
Exemplo n.º 3
0
 public static function baidugeocoding($lat, $lng)
 {
     $ak = self::getAK();
     $url = "http://api.map.baidu.com/geocoder/v2/?ak={$ak}&location={$lat},{$lng}&output=json&pois=0&coordtype=wgs84ll";
     $http_target = new HttpLib();
     $ret = $http_target->get($url);
     if ($ret['response']['code'] != 200) {
         return false;
     }
     $data = json_decode($ret['body'], true);
     if ($data['status'] != 0) {
         return false;
     }
     $geo_info = $data['result'];
     return $geo_info['formatted_address'];
 }
Exemplo n.º 4
0
 private function getCommentsFromDuoshuo()
 {
     $data = [];
     $url = "http://api.duoshuo.com/log/list.json";
     $params = ['short_name' => $this->short_name, 'secret' => $this->secret, 'since_id' => $this->getCurId($this->cur_path), 'limit' => 200, 'order' => 'asc'];
     $url .= "?" . http_build_query($params);
     $target = new HttpLib();
     $data_res = $target->get($url);
     if ($data_res['response']['code'] != 200) {
         return $data;
     }
     $commemt_list = @json_decode($data_res['body'], true);
     if ($commemt_list && $commemt_list['code'] == 0) {
         $data = $commemt_list["response"];
     }
     return $data;
 }
Exemplo n.º 5
0
 private function doubanApi($isbn, $type = 'EAN_13')
 {
     $ret = [];
     $uri = "https://api.douban.com/v2/book/isbn/:{$isbn}";
     $http = new HttpLib();
     $http_res = $http->get($uri);
     $data = $http_res['body'];
     $data = json_decode($data, true);
     if ($data) {
         $ret['isbn'] = $isbn;
         $ret['bartype'] = $type;
         $ret['name'] = '';
         $ret['subtitle'] = '';
         $ret['summary'] = "";
         $ret['tags'] = "";
         $ret['creator'] = "";
         $ret['binding'] = '';
         $ret['pages'] = "";
         $ret['publishing_house'] = "";
         $ret['publish_date'] = "";
         $ret['origin_image_url'] = '';
         if (!isset($data['code'])) {
             $ret['name'] = $data['origin_title'];
             $ret['subtitle'] = $data['title'];
             $tags = $data['tags'];
             foreach ($tags as $item) {
                 $ret['tags'][] = $item['name'];
             }
             $ret['tags'] = implode(",", $ret['tags']);
             $ret['summary'] = $data['summary'];
             $ret['creator'] = $data['author'];
             $ret['binding'] = $data['binding'];
             $ret['pages'] = $data['pages'];
             $ret['publishing_house'] = $data['publisher'];
             $ret['publish_date'] = $data['pubdate'];
             $ret['origin_image_url'] = $data['images']['large'];
         }
     }
     return $ret;
 }