Skip to content

Instantly share code, notes, and snippets.

@nishad
Forked from laiso/smaple.php
Last active August 29, 2015 14:23
Show Gist options
  • Save nishad/8974bfe3eec834108990 to your computer and use it in GitHub Desktop.
Save nishad/8974bfe3eec834108990 to your computer and use it in GitHub Desktop.
<?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