// // Source code recreated from a .class file by IntelliJ IDEA // (powered by Fernflower decompiler) // package com.wiggins.teaching.utils; import android.util.Base64; import java.io.UnsupportedEncodingException; import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; public class AESHelper { private static final String CipherMode = "AES/ECB/PKCS5Padding"; private static final String password = "Coding@xxx.China"; public AESHelper() { } private static SecretKeySpec createKey(String password) { byte[] data = null; if(password == null) { password = ""; } StringBuffer sb = new StringBuffer(16); sb.append(password); while(sb.length() < 16) { sb.append("0"); } if(sb.length() > 16) { sb.setLength(16); } try { data = sb.toString().getBytes("UTF-8"); } catch (UnsupportedEncodingException var4) { var4.printStackTrace(); } return new SecretKeySpec(data, "AES"); } public static byte[] encrypt(byte[] content, String password) { try { SecretKeySpec e = createKey(password); Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); cipher.init(1, e); byte[] result = cipher.doFinal(content); return result; } catch (Exception var5) { var5.printStackTrace(); return null; } } public static String encrypt(String content, String password) { byte[] data = null; try { data = content.getBytes("UTF-8"); } catch (Exception var4) { var4.printStackTrace(); } data = encrypt(data, password); String result = Base64.encodeToString(data, 2); return result; } public static String encrypt(String content) { byte[] data = null; try { data = content.getBytes("UTF-8"); } catch (Exception var3) { var3.printStackTrace(); } data = encrypt(data, "sgg45747ss223455"); String result = Base64.encodeToString(data, 2); return result; } public static byte[] decrypt(byte[] content, String password) { try { SecretKeySpec e = createKey(password); Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); cipher.init(2, e); byte[] result = cipher.doFinal(content); return result; } catch (Exception var5) { var5.printStackTrace(); return null; } } public static String decrypt(String content, String password) { byte[] data = null; try { data = Base64.decode(content, 2); } catch (Exception var6) { var6.printStackTrace(); } data = decrypt(data, password); if(data == null) { return null; } else { String result = null; try { result = new String(data, "UTF-8"); } catch (UnsupportedEncodingException var5) { var5.printStackTrace(); } return result; } } public static String decrypt(String content) { byte[] data = null; try { data = Base64.decode(content, 2); } catch (Exception var5) { var5.printStackTrace(); } data = decrypt(data, "sgg45747ss223455"); if(data == null) { return null; } else { String result = null; try { result = new String(data, "UTF-8"); } catch (UnsupportedEncodingException var4) { var4.printStackTrace(); } return result; } } public static String byte2hex(byte[] b) { StringBuffer sb = new StringBuffer(b.length * 2); String tmp = ""; for(int n = 0; n < b.length; ++n) { tmp = Integer.toHexString(b[n] & 255); if(tmp.length() == 1) { sb.append("0"); } sb.append(tmp); } return sb.toString().toUpperCase(); } private static byte[] hex2byte(String inputString) { if(inputString != null && inputString.length() >= 2) { inputString = inputString.toLowerCase(); int l = inputString.length() / 2; byte[] result = new byte[l]; for(int i = 0; i < l; ++i) { String tmp = inputString.substring(2 * i, 2 * i + 2); result[i] = (byte)(Integer.parseInt(tmp, 16) & 255); } return result; } else { return new byte[0]; } } }
<?php namespace icecry; /** * aes 加密 解密类库 * @by singwa */ class Aes { private $key = null; /** * * @param $key 密钥 * @return String */ public function __construct() { $this->key = 'Coding@xxx.China'; } /** * 加密 * @param String input 加密的字符串 * @param String key 解密的key * @return HexString */ public function encrypt($input = '') { $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB); $input = $this->pkcs5_pad($input, $size); $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, ''); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); mcrypt_generic_init($td, $this->key, $iv); $data = mcrypt_generic($td, $input); mcrypt_generic_deinit($td); mcrypt_module_close($td); $data = base64_encode($data); return $data; } /** * 填充方式 pkcs5 * @param String text 原始字符串 * @param String blocksize 加密长度 * @return String */ private function pkcs5_pad($text, $blocksize) { $pad = $blocksize - (strlen($text) % $blocksize); return $text . str_repeat(chr($pad), $pad); } /** * 解密 * @param String input 解密的字符串 * @param String key 解密的key * @return String */ public function decrypt($sStr) { $decrypted= mcrypt_decrypt(MCRYPT_RIJNDAEL_128,$this->key,base64_decode($sStr), MCRYPT_MODE_ECB); $dec_s = strlen($decrypted); $padding = ord($decrypted[$dec_s-1]); $decrypted = substr($decrypted, 0, -$padding); return $decrypted; } }
聚米田小田SEO课程基础课 – SEO基础知识大家晚上好，我是hitortoise ! 一个程序员，俗称码农，简单的说就是一个做网站的。2014年因为所在公司发展微商而接触微商，加上之后开发、运营了微信好多群网站：www.haoduoqun.com接触到了更多的微商包括更多的一些微商产品，可惜的是，由于种种原因，好多群网站现在也已经关站。好多群网站群里可能有的朋友使用过，当时日访客UV过万，PV过17万，百度自然排名一段时间内第一。[...]
很多程序员一看就知道不会创业“程序员思维”会害死你！在IT这一行做得久了，会接触到无数让人哭笑不得的外行话。「我们就差一个写代码的了」是其中典型的一种，之所以黑它，不是因为程序员有多自大，认为自己被轻视所以愤怒。而是因为说这句话的人里有90%以上绝对不仅仅差一个写代码的，而是一整套技术体系。那么，程序员在创业公司之中真的这么重要吗？？？[...]
<?php /** * 百度 LBS云图数据接口 * Author: IceCry <http://www.zhinizhiwo.com> * Date: 2017-10-14 15:51 * * 云存储使用V3 V4暂不支持云检索 * 暂不使用sn签名 * 百度LBS.云 http://lbsyun.baidu.com/index.php?title=lbscloud */ namespace ice; class Bmap { private static $ak; private static $tableid; public function __construct($ak='', $tableid=0) { if($ak===''){ die('ak required !'); } self::$ak = $ak; self::$tableid = $tableid; } /** * 创建位置数据表 * * @param <type> $name 中文表名 * @param integer $geotype 数据类型 1点 2线(暂不支持) 3面 * @param integer $is_published 是否发布到云检索 1自动发布到检索 */ public function create_table($name, $geotype=1, $is_published=0, $sn='', $timestamp=0) { $url = 'http://api.map.baidu.com/geodata/v3/geotable/create'; $data = [ 'ak' => self::$ak, 'name' => $name, 'geotype' => $geotype, 'is_published' => $is_published ]; $res = $this->https_request($url, $data); return $res; } /** * 查询表 * * @param string $name 表名 可选 * @param string $sn 签名 * * @return <type> ( description_of_the_return_value ) */ public function search_table($name='', $sn='') { $url = 'http://api.map.baidu.com/geodata/v3/geotable/list'; $data = [ 'ak' => self::$ak, 'name' => $name ]; $res = $this->https_request($url, $data, true); return $res; } /** * 查询指定id表 * * @param integer $id id * @param string $sn sn * * @return <type> ( description_of_the_return_value ) */ public function search_id($id=0, $sn='') { $url = 'http://api.map.baidu.com/geodata/v3/geotable/detail'; $data = [ 'ak' => self::$ak, 'id' => $id ]; $res = $this->https_request($url, $data, true); return $res; } /** * 修改表 * * @param integer $id 表id * @param integer $is_published 是否为云检索 * @param string $name 表名 * @param string $sn The serial number * * @return <type> ( description_of_the_return_value ) */ public function update_table($id=0, $is_published=0, $name='', $sn='') { $url = 'http://api.map.baidu.com/geodata/v3/geotable/update'; $data = [ 'ak' => self::$ak, 'id' => $id, 'name' => $name, 'is_published' => $is_published, 'sn' => $sn ]; $res = $this->https_request($url, $data); return $res; } /** * 删除表 只能删除空表 * * @param integer $id 表id * @param string $sn The serial number */ public function delete_table($id=0, $sn='') { $url = 'http://api.map.baidu.com/geodata/v3/geotable/delete'; $data = [ 'ak' => self::$ak, 'id' => $id, 'sn' => $sn ]; $res = $this->https_request($url, $data); return $res; } /** * 创建/更新列 * * @param string $name 中文列名 * @param string $key 列名 * @param integer $type 值类型 枚举值1:Int64, 2:double, 3:string, 4:在线图片url * @param integer $max_length 最大长度 1-2048 type为string有效 汉字数 * @param string $default_value 默认值 * @param integer $is_sortfilter_field 是否排序筛选 * @param integer $is_search_field 是否文本检索 * @param integer $is_index_field 是否存储引擎的索引字段 * @param integer $is_unique_field 是否唯一索引 * @param string $sn 权限签名 */ public function deal_column($id=0, $name='', $key='', $type=0, $max_length=0, $default_value='', $is_sortfilter_field=0, $is_search_field=0, $is_index_field=0, $is_unique_field=0, $sn='') { $url = 'http://api.map.baidu.com/geodata/v3/column/create'; $data = [ 'ak' => self::$ak, 'name' => $name, 'key' => $key, 'type' => $type, 'max_length' => $max_length, 'default_value' => $default_value, 'is_sortfilter_field' => $is_sortfilter_field, 'is_search_field' => $is_search_field, 'is_index_field' => $is_index_field, 'is_unique_field' => $is_unique_field, 'geotable_id' => self::$tableid, 'sn' => $sn ]; //如果存在id则更新 if($id){ $url = 'http://api.map.baidu.com/geodata/v3/column/update'; $data['id'] = $id; } $res = $this->https_request($url, $data); return $res; } /** * 查询列 * * @param string $name 表名 可选 * @param string $key 属性key * @param string $sn 签名 * * @return <type> ( description_of_the_return_value ) */ public function search_column($name='', $key='', $sn='') { $url = 'http://api.map.baidu.com/geodata/v3/column/list'; $data = [ 'ak' => self::$ak, 'geotable_id' => self::$tableid, 'name' => $name, 'key' => $key, 'sn' => $sn ]; $res = $this->https_request($url, $data, true); return $res; } /** * 查询指定id列数据 * * @param integer $id The identifier * @param string $sn The serial number */ public function search_column_id($id=0, $sn='') { $url = 'http://api.map.baidu.com/geodata/v3/column/detail'; $data = [ 'ak' => self::$ak, 'geotable_id' => self::$tableid, 'id' => $id, 'sn' => $sn ]; $res = $this->https_request($url, $data, true); return $res; } /** * 删除指定列 * * @param integer $id 列id * @param string $sn 签名 * * @return <type> ( description_of_the_return_value ) */ public function delete_column($id=0, $sn='') { $url = 'http://api.map.baidu.com/geodata/v3/column/delete'; $data = [ 'ak' => self::$ak, 'geotable_id' => self::$tableid, 'id' => $id, 'sn' => $sn ]; $res = $this->https_request($url, $data); return $res; } /** * 创建地理位置 * * @param string $title poi名称 * @param string $address 地址 * @param string $tags 标签 * @param <type> $latitude 纬度 * @param <type> $longitude 经度 * @param integer $coord_type 坐标类型 1：GPS经纬度坐标 2：国测局加密经纬度坐标 3：百度加密经纬度坐标 4：百度加密墨卡托坐标 * @param string $diy 自定义数据 * @param string $sn 签名 * @param string $diyvalue 自定义唯一索引key */ public function deal_poi($id=0, $title='', $address='', $tags='', $latitude, $longitude, $coord_type=3, $diy=array(), $sn='', $diyvalue='') { $data = [ 'ak' => self::$ak, 'geotable_id' => self::$tableid, 'title' => $title, 'address' => $address, 'tags' => $tags, 'latitude' => $latitude, 'longitude' => $longitude, 'coord_type' => $coord_type ]; $url = 'http://api.map.baidu.com/geodata/v3/poi/create'; if($id){ $url = 'http://api.map.baidu.com/geodata/v3/poi/update'; $data['id'] = $id; } $data = array_merge($data, $diy); $res = $this->https_request($url, $data); return $res; } /** * 查询指定条件poi * * @param array $diy 自定义数据 is_index_field=1 string加$精准匹配 * @param string $title 标题 * @param string $tags 标签 * @param string $bounds 矩形区域 * @param integer $page_index 分页 * @param integer $page_size 页面大小 * @param string $sn 签名 */ public function search_poi_list($diy=[], $title='', $tags='', $bounds='', $page_index=0, $page_size=10, $sn='') { $url = 'http://api.map.baidu.com/geodata/v3/poi/list'; $data = [ 'ak' => self::$ak, 'geotable_id' => self::$tableid, 'title' => $title, 'tags' => $tags, 'bounds' => $bounds, 'page_index' => $page_index, 'page_size' => $page_size ]; $data = array_merge($data, $diy); $res = $this->https_request($url, $data, true); return $res; } /** * 查询指定id的数据 * * @param integer $id id * @param string $sn 签名 * * @return <type> ( description_of_the_return_value ) */ public function search_id_poi($id=0, $sn='') { $url = 'http://api.map.baidu.com/geodata/v3/poi/detail'; $data = [ 'ak' => self::$ak, 'geotable_id' => self::$tableid, 'id' => $id ]; $res = $this->https_request($url, $data, true); return $res; } /** * 删除poi 支持批量删除 * * @param integer $id 删除单条 存在则其他条件无效 * @param string $diyvalue 自定义唯一索引 * @param string $ids 删除id列表1,2,3 批量删除尽可能使用此方法 <1000 * @param array $diyIndex 用户自定义 需设置is_index_field=1 * @param string $title 名称 * @param string $tags 标签 * @param string $bounds 矩形区域 * @param array $diyColumn 自定义 * @param integer $is_total_del 标记为批量删除 若仅设置为1不指定条件则删除全表 * @param string $sn 签名 */ public function delete_poi($id=0, $diyvalue='', $ids='', $diyIndex=array(), $title='', $tags='', $bounds='', $diyColumn=array(), $is_total_del=0, $sn='') { $url = 'http://api.map.baidu.com/geodata/v3/poi/delete'; $data = [ 'ak' => self::$ak, 'geotable_id' => self::$tableid, 'id' => $id, 'diyvalue' => $diyvalue, 'ids' => $ids, 'title' => $title, 'tags' => $tags, 'bounds' => $bounds, 'is_total_del' => $is_total_del ]; $arr = array_merge($diyIndex, $diyColumn); $data = array_merge($data, $arr); if(!$id){ unset($data['id']); } $res = $this->https_request($url, $data); return $res; } /** * 批量上传数据 暂无用 每日限调用25次 */ public function create_multi_data() { $url = 'http://api.map.baidu.com/geodata/v3/poi/upload'; } /** * 批量上传进度查询接口 暂无用 */ public function create_multi_progress() { $url = ''; } /** * 批量操作查询结果 暂无用 */ public function multi_job_search() { } /** * 云检索 周边检索 * * @param string $q 检索关键词 * @param string $location 经纬度 * @param integer $coord_type 坐标系 3百度经纬度 * @param integer $radius 检索半径 * @param string $tags 标签 * @param string $sortby 排序字段 * @param string $filter 过滤条件 * @param integer $page_index 分页索引 * @param integer $page_size 分页数量 * @param string $callback 回调函数 * @param string $sn * * @return <type> ( description_of_the_return_value ) */ public function search_nearby($q='', $location='', $coord_type=3, $radius=1000, $tags='', $sortby='', $filter='', $page_index=0, $page_size=10, $callback='', $sn='') { $url = 'http://api.map.baidu.com/geosearch/v3/nearby'; $data = [ 'ak' => self::$ak, 'geotable_id' => self::$tableid, 'q' => $q, 'location' => $location, 'coord_type' => $coord_type, 'radius' => $radius, 'tags' => $tags, 'sortby' => $sortby, 'filter' => $filter, 'page_index' => $page_index, 'page_size' => $page_size ]; $res = $this->https_request($url, $data, true); return $res; } /** * 云检索 本地检索 * * @param string $q 查询字符 * @param integer $coord_type 坐标类型 * @param string $region 检索区域 默认全国 * @param string $tags 标签 * @param string $sortby 排序 * @param string $filter 过滤 * @param integer $page_index 分页索引 * @param integer $page_size 分页数量 * @param string $callback 回调函数 * @param string $sn The serial number */ public function search_local($q='', $coord_type=3, $region='', $tags='', $sortby='', $filter='', $page_index=0, $page_size=10, $callback='', $sn='') { $url = 'http://api.map.baidu.com/geosearch/v3/local'; $data = [ 'ak' => self::$ak, 'geotable_id' => self::$tableid, 'q' => $q, 'coord_type' => $coord_type, 'region' => $region, 'tags' => $tags, 'sortby' => $sortby, 'filter' => $filter, 'page_index' => $page_index, 'page_size' => $page_size ]; $res = $this->https_request($url, $data, true); return $res; } /** * 云检索 矩形检索 * * @param string $q 查询内容 * @param string $bounds 矩形区域 * @param string $tags The tags * @param integer $coord_type The coordinate type * @param string $sortby The sortby * @param string $filter The filter * @param integer $page_index The page index * @param integer $page_size The page size * @param string $callback The callback * @param string $sn The serial number * * @return <type> ( description_of_the_return_value ) */ public function search_bound($q='', $bounds='', $tags='', $coord_type=3, $sortby='', $filter='', $page_index=0, $page_size=10, $callback='', $sn='') { $url = 'http://api.map.baidu.com/geosearch/v3/bound'; $data = [ 'ak' => self::$ak, 'geotable_id' => self::$tableid, 'q' => $q, 'bounds' => $bounds, 'tags' => $tags, 'coord_type' => $coord_type, 'sortby' => $sortby, 'filter' => $filter, 'page_index' => $page_index, 'page_size' => $page_size ]; $res = $this->https_request($url, $data, true); return $res; } /** * 云检索 poi详情检索 * * @param integer $uid poi点的id值 * @param integer $coord_type The coordinate type * @param string $sn The serial number * * @return <type> ( description_of_the_return_value ) */ public function search_poi_detail($uid=0, $coord_type=3, $sn='') { $url = 'http://api.map.baidu.com/geosearch/v3/detail/'.$uid; $data = [ 'ak' => self::$ak, 'geotable_id' => self::$tableid, 'coord_type' => $coord_type ]; $res = $this->https_request($url, $data, true); return $res; } /** * curl * * @param <type> $url The url * @param <type> $data The data * @param <type> $isget 是否为get请求 * * @return <type> ( description_of_the_return_value ) */ public function https_request($url, $data = null, $isget = false) { $headers = array( 'Cache-Control:no-cache', 'Pragma:no-cache' ); if($isget){ $url .= '?'; if(is_array($data)){ $url .= http_build_query($data); }elseif(is_string($data)) { $url .= $data; } } $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($curl, CURLOPT_TIMEOUT,3); if (!empty($data) && !$isget){ curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $output = curl_exec($curl); curl_close($curl); return $output; } }
TP5 位置：/extends/ice/Amap.php 使用：use ice\Amap<?php /** * 高德云图数据接口 * Author: IceCry <http://www.zhinizhiwo.com> * Date: 2017-10-14 09:01 */ namespace ice; class Amap { private static $key; private static $tableid; public function __construct($key='', $tableid='') { if($key===''){ die('key required !'); } self::$key = $key; self::$tableid = $tableid; } /** * 创建云图数据表 * * @param <type> $name 表名 * @param <type> $name 数字前面 * * http://yuntuapi.amap.com/datamanage/table/create * 返回值 status info tableid */ public function create_table($name='', $sig='') { $name = $name ? $name : date('YmdHis'); $url = "http://yuntuapi.amap.com/datamanage/table/create"; $data = [ 'key' => self::$key, 'name' => $name, 'sig' => $sig ]; $res = $this->https_request($url, $data); return $res; } /** * 创建单条位置信息 * * @param <type> $loctype 定位方式 1经纬度 2地址 * @param <type> $_location 经纬度 * @param <type> $_address 地址 * @param <type> $_name 数据名称 * @param <type> $coordtype 坐标类型 1: gps 2: autonavi 3: baidu * @param <type> $sig 数字签名 * @param <type> $diy 用户自定义数据 * * http://yuntuapi.amap.com/datamanage/data/create * 返回值 status info _id */ public function deal_single_data($loctype=1, $_location='', $_address='', $_name='', $coordtype='3', $sig='', $diy=array(), $isUpdate=false) { $url = 'http://yuntuapi.amap.com/datamanage/data/create'; if($isUpdate){ $url = 'http://yuntuapi.amap.com/datamanage/data/update'; } //基础信息 仅处理经纬度方式 $info = [ '_name' => $_name, '_location' => $_location, 'coordtype' => $coordtype, '_address' => $_address, ]; $info = json_encode(array_merge($info, $diy)); $data = [ 'key' => self::$key, 'tableid' => self::$tableid, 'loctype' => $loctype, 'data' => $info ]; $res = https_request($url, $data); return $res; } /** * 暂无用 使用高德后台上传 */ public function add_multi_data() { } /** * 删除单条/多条数据 * * @param string $ids 数据1-50条 _id 1,3,4 * @param string $sig The signal * * 返回值 status info success fail成功/失败条数 */ public function delete_data($ids='', $sig='') { $url = "http://yuntuapi.amap.com/datamanage/data/delete"; $data = [ 'key' => self::$key, 'tableid' => self::$tableid, 'ids' => $ids, 'sig' => $sig ]; $res = $this->https_request($url, $data); $res = json_decode($res); return $res; } /** * 获取批量处理进度 暂无用 */ public function get_import_status() { } /** * 云检索 本地检索 * * @param string $keywords 搜索关键词 * @param string $city 中文城市 * @param string $filter 过滤条件 * @param string $sortrule 排序规则 * @param string $limit 分页条数 * @param string $page 当前页 * @param string $sig 数字签名 */ public function search_local($keywords=' ', $city='全国', $filter='', $sortrule='', $limit=10, $page=1, $sig='') { $url = 'http://yuntuapi.amap.com/datasearch/local'; $data = [ 'key' => self::$key, 'tableid' => self::$tableid, 'keywords' => $keywords, 'city' => $city, 'filter' => $filter, 'sortrule' => $sortrule, 'limit' => $limit, 'page' => $page, 'sig' => $sig ]; $res = $this->https_request($url, $data, true); return $res; } /** * 云检索 周边检索 * * @param string $keywords 搜索关键词 * @param string $center 中心经纬度 * @param string $radius 查询半径 * @param string $filter 过滤条件 * @param string $sortrule 排序规则 * @param string $limit 分页条数 * @param string $page 当前页 * @param string $sig 数字签名 */ public function search_around($keywords=' ', $center='119.168162,36.713983', $radius='3000', $filter='', $sortrule='', $limit=10, $page=1, $sig='') { $url = 'http://yuntuapi.amap.com/datasearch/around'; $data = [ 'key' => self::$key, 'tableid' => self::$tableid, 'keywords' => $keywords, 'center' => $center, 'radius' => $radius, 'filter' => $filter, 'sortrule' => $sortrule, 'limit' => $limit, 'page' => $page, 'sig' => $sig ]; $res = $this->https_request($url, $data, true); return $res; } /** * 多边形检索 暂无用 */ public function search_polygon() { } /** * 云检索 id检索（poi详情检索） * * @param string $_id 地图数据id * @param string $sig 数字签名 * * @return <type> ( description_of_the_return_value ) */ public function search_id($_id='', $sig='') { $url = 'http://yuntuapi.amap.com/datasearch/id'; $data = [ 'key' => self::$key, 'tableid' => self::$tableid, '_id' => $_id, 'sig' => $sig ]; $res = $this->https_request($url, $data, true); return $res; } /** * 云检索 按条件检索数据（可遍历整表数据） * * @param string $filter 过滤条件 * @param string $sortrule 排序规则 * @param string $limit 分页条数 * @param string $page 当前页 * @param string $sig 数字签名 */ public function search_by_condition($filter='', $sortrule='', $limit=10, $page=1, $sig='') { $url = 'http://yuntuapi.amap.com/datamanage/data/list'; $data = [ 'key' => self::$key, 'tableid' => self::$tableid, 'filter' => $filter, 'sortrule' => $sortrule, 'limit' => $limit, 'page' => $page, 'sig' => $sig ]; $res = $this->https_request($url, $data, true); return $res; } /** * 云检索 数据分布检索 * * @param string $keywords 搜索关键词 * @param string $center 中心经纬度 * @param string $radius 查询半径 * @param string $filter 过滤条件 * @param string $sortrule 排序规则 * @param string $limit 分页条数 * @param string $page 当前页 * @param string $sig 数字签名 */ public function search_area_count($keywords=' ', $type='', $country='中国', $province='', $city='', $filter='', $sig='', $callback='cb') { $data = [ 'key' => self::$key, 'tableid' => self::$tableid, 'filter' => $filter, // 'callback' => $callback, 'sig' => $sig ]; switch ($type) { case 'province': $url = 'http://yuntuapi.amap.com/datasearch/statistics/province'; $data['country'] = $country; break; case 'city': $url = 'http://yuntuapi.amap.com/datasearch/statistics/city'; $data['province'] = $province; break; case 'district': $url = 'http://yuntuapi.amap.com/datasearch/statistics/district'; $data['province'] = $province; $data['city'] = $city; break; default: $url = ''; break; } $res = $this->https_request($url, $data, true); return $res; } /** * curl * * @param <type> $url The url * @param <type> $data The data * @param <type> $isget 是否为get请求 * * @return <type> ( description_of_the_return_value ) */ public function https_request($url, $data = null, $isget = false) { $headers = array( 'Cache-Control:no-cache', 'Pragma:no-cache' ); if($isget){ $url .= '?'; if(is_array($data)){ $url .= http_build_query($data); }elseif(is_string($data)) { $url .= $data; } } $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($curl, CURLOPT_TIMEOUT,3); if (!empty($data) && !$isget){ curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $output = curl_exec($curl); curl_close($curl); return $output; } }