Created
March 1, 2025 12:30
-
-
Save thinkphp/1bc88f7be83aaeedff9606c4414d4934 to your computer and use it in GitHub Desktop.
foursquare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function testFoursquareAPI() { | |
const API_KEY = 'fsq3agVQLNiAKtKnzwe53yyFL0AYlwnuqcaolD0V8Dl+ssg='; | |
const endpoint = 'https://api.foursquare.com/v3/places/search?near=Sibiu,Romania&limit=3'; | |
try { | |
console.log('🔍 Testing Foursquare API connection...'); | |
const response = await fetch(endpoint, { | |
headers: { | |
'Authorization': API_KEY, | |
'Accept': 'application/json' | |
} | |
}); | |
const data = await response.json(); | |
if (response.ok) { | |
console.log('✅ API Key is working!'); | |
if (data.results?.length > 0) { | |
const place = data.results[0]; | |
console.log(data.results) | |
console.log('📍 First Place Found:', { | |
name: place.name, | |
address: place.location.address, | |
lat: place.geocodes?.main?.latitude, | |
lng: place.geocodes?.main?.longitude | |
}); | |
} else { | |
console.log('⚠️ No places found.'); | |
} | |
} else { | |
console.error('❌ API Key is not working:', data); | |
} | |
} catch (error) { | |
console.error('❌ Error testing API:', error); | |
} | |
} | |
testFoursquareAPI(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment