PHP code example of aoxiang / baidu-yingyan

1. Go to this page and download the library: Download aoxiang/baidu-yingyan library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aoxiang / baidu-yingyan example snippets


$ak        = 'yU1QNKOLqn7FqZMjLLxqI2dF';
$server_id = '220271';
$yingyan   = new YingYan($ak, $server_id);
//添加终端
$res = $yingyan->addEntity('aoxiang-test');
//删除终端
$res = $yingyan->deleteEntity('aoxiang-test-165');
//修改终端
$res = $yingyan->updateEntity('123456', '测试修改描述','');
//获取终端列表
$res = $yingyan->getEntityList();
//为终端名为123456中终端,上传轨迹点
$res = $yingyan->addTrack('123456', 39.220121, 116.46365, 1586586922, 'bd09ll',
    ['speed'     => 100,
     'direction' => '23',
     'height'    => 300,
    ]);
//批量上传轨迹点
//先造一些假数据
$item = [
    'entity_name'      => '123456',
    'latitude'         => 30.691794,
    'longitude'        => 117.860935,
    'loc_time'         => 1586574000,
    'coord_type_input' => 'bd09ll',
    'speed'            => 100,
    'direction'        => '23',
    'height'           => 300,
];
for ($i = 0; $i < 20; $i++) {
    $item   = [
        'entity_name'      => '123456',
        'latitude'         => $item['latitude'] + $i * 0.0001 * rand(1, 100),
        'longitude'        => $item['longitude'] + $i * 0.0001 * rand(1, 100),
        'loc_time'         => strval($item['loc_time'] + $i * rand(1, 60)),
        'coord_type_input' => 'bd09ll',
        'speed'            => 100,
        'direction'        => '23',
        'height'           => 300,
    ];
    $list[] = $item;
}
$res = $yingyan->addTrackList( $list);