Skip to content

k1ttyf/geospy-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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