本人要写一个餐饮网站,要搜索客户所属区域的店铺,请问如何做到。本人想用百度的lbs云可是总是报101 ak参数不存在的错误,代码如下:
public function createtable(){
$url="http://api.map.baidu.com/geodata/v3/geotable/create";
$data=array();
$data['name']="ktable";
$data['geotype']=1;
$data['is_published']=1;
$data['ak']="WXKcVBH1bFcGAsm6eQuwFBXh";
$data['timestamp']=time();
$json=json_encode($data);
$ujson=urlencode($json);
//$data=urlencode($data);
dump($json);
$re=$this->wxpost($url,$ujson);
dump($re);
}
private function wxpost($url,$postdata){
$ch = curl_init();//初始化curl
curl_setopt($ch,CURLOPT_URL,$url);//抓取指定网页
curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
//curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/x-www-form-urlencoded'));
//curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json;charset=utf-8'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
$data = curl_exec($ch);//运行curl
curl_close($ch);
return $data;
}
然后就想用其他方法来做了?所以前来请问一下有什么方法?
人生最曼妙的风景,竟是内心的淡定与从容!