Skip to content

Latest commit

 

History

History
61 lines (48 loc) · 1.99 KB

README.md

File metadata and controls

61 lines (48 loc) · 1.99 KB

k1ttyf/geospy-php

SDK for using GeoSpy API in PHP. Based on GeoSpy API.

License Packagist Downloads GitHub release (latest by date including pre-releases) GitHub last commit

🛠 Install

Run this command at the command prompt:

composer require k1ttyf/geospy-php

🔌 Usage

<?php

$image = __DIR__ . "/image.jpeg";
require_once __DIR__ . "/vendor/autoload.php";
$GeoSpy = new k1ttyf\GeoSpy\API("YOUR_API_KEY");

try {
    $result = $GeoSpy->predict($image);
    foreach($result["geo_predictions"] as $value){
        echo "Latitude: " . $value["coordinates"][0] . PHP_EOL;
        echo "Longitude: " . $value["coordinates"][1] . PHP_EOL;
        foreach($GeoSpy->getLocationLinks($value["coordinates"][0], $value["coordinates"][1]) as $service => $link){
            echo ucfirst($service) . ": " . $link . PHP_EOL;
        }
        echo "Score: " . $value["score"] . PHP_EOL;
        echo "Similarity Score (1km): " . $value["similarity_score_1km"] . PHP_EOL;
        echo "Address: " . $value["address"] . PHP_EOL;
        echo PHP_EOL;
    }
} catch(Exception $e){
    echo "Error: " . $e->getMessage() . PHP_EOL;
}

getLocationLinks

<?php

$latitude = 48.858112335205;
$longitude = 2.2949459552765;

require_once __DIR__ . "/vendor/autoload.php";
$GeoSpy = new k1ttyf\GeoSpy\API("YOUR_API_KEY");

foreach($GeoSpy->getLocationLinks($latitude, $longitude) as $service => $link){
    echo ucfirst($service) . ": " . $link . PHP_EOL;
}

💣 Troubleshooting

Please if you find any errors or inaccuracies - report it