PHP code example of rbit / milk-sdk-php

1. Go to this page and download the library: Download rbit/milk-sdk-php 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/ */

    

rbit / milk-sdk-php example snippets



// include the autoload.php file
bit\Milk\Xyz\Space\XyzSpace;
// load environment configuration (via Dotenv)
Dotenv\Dotenv::createImmutable(__DIR__)->load();
// get your Token
$xyzToken = getenv("XYZ_ACCESS_TOKEN");
// Get your XYZ Spaces
$s = XyzSpace::instance($xyzToken)->get();
// display your result
var_dump($s);

$s = XyzSpace::instance($xyzToken)->get();

$s =  XyzSpace::instance($xyzToken)->ownerAll()->get();

$xyzSpaceDeleted = XyzSpace::instance($xyzToken)->delete($spaceId);

$xyzSpaceCreated = XyzSpace::instance($xyzToken)->create("My Space", "Description");

$obj = new \stdClass;
$obj->title = "Edited Title";
$obj->description = "Edited Description";
$retVal = $space->update($spaceId, $obj);

$statistics =  XyzSpaceStatistics::instance($xyzToken)->spaceId($spaceId)->get();

/** XyzSpaceFeature $xyzSpaceFeature */
$xyzSpaceFeature = new XyzSpaceFeature::instance($xyzToken);
$result = $xyzSpaceFeature->iterate($spaceId)->get();

$xyzSpaceFeature = XyzSpaceFeature::instance($xyzToken);
$result = $xyzSpaceFeature->feature($featureId, $spaceId)->get();

$spaceId = "yourspaceid";
$featureId = "yourfeatureid";
$geoJson = new GeoJson();
$properties = [
    "name" => "Berlin",
    "op" => "Put"
];
$geoJson->addPoint(52.5165, 13.37809, $properties, $featureId);
$feature = XyzSpaceFeatureEditor::instance($xyzToken);
$result = $feature->feature($geoJson->get())->saveOne($spaceId, $featureId);
$feature->debug();

$spaceId = "yourspaceid";
$file = "https://data.cityofnewyork.us/api/geospatial/arq3-7z49?method=export&format=GeoJSON";
$response = XyzSpaceFeatureEditor::instance($xyzToken)
    ->addTags(["file"])
    ->geojson($file)
    ->create($spaceId);

$spaceId = "yourspaceid";
$xyzSpaceFeature = XyzSpaceFeature::instance($xyzToken)->addSearchParams("p.name", "Colosseo");
$result = $xyzSpaceFeature->search($spaceId)->get();

$spaceId = "yourspaceid";
$result = XyzSpaceFeature::instance($xyzToken)->spatial($spaceId,  41.890251, 12.492373,  1000)->get();

$jsonWeather = ApiWeather::instance($hereApiKey)
    ->productForecast7days()
    ->name("Berlin")
    ->getJson();
var_dump($jsonWeather);

$r =RoutingV7::instance($hereApiKey)
  ->byFoot()
  ->typeFastest()
  ->startingPoint(52.5160,13.3779)
  ->destination(52.5185,13.4283)
  ->getManeuverInstructions();

$routing = RoutingV8::instance($hereApiKey)
    ->byCar()
    ->routingModeFast()
    ->startingPoint(52.5160, 13.3779)
    ->destination(52.5185, 13.4283)
    ->returnInstructions()
    ->langIta()
    ->get();