52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?
|
|
|
|
namespace controller\common\dadata;
|
|
|
|
|
|
use integration\Dadata;
|
|
use ms\ms\structure\msControllerTable;
|
|
|
|
class Api extends msControllerTable {
|
|
|
|
static $API_KEY = 'e45db0a91196d2ac2f8748be57cb8dfeb085c9bf';
|
|
|
|
static function searchOrgForShop(){
|
|
$res = [];
|
|
if(IF_VISIT){
|
|
$res = Dadata::getOrg(self::$API_KEY, $_REQUEST['q'], []);
|
|
}
|
|
echo je( $res );
|
|
}
|
|
static function searchAddressForShop(){
|
|
$res = [];
|
|
if(IF_VISIT){
|
|
$r = Dadata::getAddress(self::$API_KEY, $_REQUEST['q'], [
|
|
//"to_bound" => [ "value" => "city" ],
|
|
]);
|
|
foreach ($r as $v){
|
|
$d = $v['data'];
|
|
$val = [];
|
|
//if($c = $d['country']) $val[] = $c;
|
|
//if($c = $d['region']) $val[] = $c;
|
|
if($c = $d['city_type']) $val[] = $c;
|
|
if($c = $d['city']) $val[] = $c;
|
|
if($c = $d['street_type']) $val[] = $c;
|
|
if($c = $d['street']) $val[] = $c;
|
|
if($c = $d['house_type']) $val[] = $c;
|
|
if($c = $d['house']) $val[] = $c;
|
|
if($c = $d['block_type']) $val[] = $c;
|
|
if($c = $d['block']) $val[] = $c;
|
|
|
|
|
|
$title = implode(" ",$val);
|
|
$res[] = [
|
|
'title'=>$title,
|
|
//'value'=>$val,
|
|
];
|
|
}
|
|
}
|
|
echo je( $res );
|
|
}
|
|
|
|
}
|