Skip to content
Snippets Groups Projects
Commit 05ae6f99 authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Add support for JSONP at country API endpoint

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2906 44740490-163a-0410-bde0-09ae8108e29a
parent 9c2b4441
No related branches found
No related tags found
No related merge requests found
<?php
header('Content-type: application/json; utf-8');
try {
......@@ -29,8 +28,16 @@ try {
$result['geo'] = array('lat' => (float) $matches[1], 'lon' => (float)$matches[2]);
}
echo json_encode($result); exit;
throw new Exception('Could not lookup, invalid format: ' . $region);
if(preg_match('/^[0-9A-Za-z_\-]+$/', $_REQUEST['callback'], $matches)) {
header('Content-type: application/javascript; utf-8');
echo $_REQUEST['callback'] . '(' . json_encode($result) . ');';
} else {
header('Content-type: application/json; utf-8');
echo json_encode($result);
}
} catch(Exception $e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment