Created
December 7, 2011 13:16
-
-
Save laiso/1442762 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Exite翻訳(英語→日本語)の野良API サンプル | |
*/ | |
$text = 'This is a pen.'; | |
$to = 'ENJA'; // ENJA or JAEN | |
$q = http_build_query(array( | |
'_id' => '6855579bdcb52e1a0a3822af4b5a9c88', | |
'_render' => 'json', | |
'before' => urlencode($text), | |
'to' => $to | |
)); | |
$response = file_get_contents('http://pipes.yahoo.com/pipes/pipe.run?' . $q); | |
$apidata = json_decode($response); | |
$from = $apidata->value->items[0]->content; | |
$to = $apidata->value->items[1]->content; | |
?> | |
<html> | |
<body> | |
<p><?php echo htmlspecialchars($from);?></p> | |
<p>↓</p> | |
<p><?php echo htmlspecialchars($to);?></p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment