Created
October 24, 2010 04:37
-
-
Save kanreisa/643105 to your computer and use it in GitHub Desktop.
XMLデータをJavaScriptで扱うためのJSONP変換APIサンプル
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
<?php | |
if( ($_GET['xml'])&&($_GET['callback']) ) | |
{ | |
$url = strip_tags($_GET['xml']); | |
$callback = strip_tags($_GET['callback']); | |
header('Content-Type: text/javascript; charset=utf-8'); | |
if( $xml = @simplexml_load_file('http://' . $url) ) { | |
$json = json_encode($xml); | |
} else { | |
$json = 'null'; | |
} | |
echo $callback . '(' . $json . ');'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ライセンスフリー。
実際に利用する場合はキャッシュなどしてやってください。