k1ttyf / geospy-php
The Unofficial GeoSpy API PHP SDK
v1.2.1
2025-01-13 00:07 UTC
Requires
- php: >=8.0
- guzzlehttp/guzzle: ^7.5.1
README
SDK for using GeoSpy API in PHP. Based on GeoSpy API.
🛠Install
Run this command at the command prompt:
composer require k1ttyf/geospy-php
🔌 Usage
Predict
<?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