Yahoo! Term Extraction API V1
if (array_key_exists('submit', $_REQUEST)) {
$url = 'http://search.yahooapis.com/ContentAnalysisService/V1/termExtraction';
$appid = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$output = 'php';
if (array_key_exists('string', $_REQUEST) && strlen($_REQUEST['string']) > 0) {
$context = urlencode($_POST['string']);
} else if (array_key_exists('url', $_REQUEST) && strlen($_REQUEST['url']) > 0) {
$context = urlencode(strip_tags(file_get_contents($_REQUEST['url'])));
}
$context = substr($context, 0, 7000);
$url = $url . '?appid=' . $appid . '&output=' . $output . '&context=' . $context;
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// grab URL and pass it to the browser
$response = curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
$response = unserialize($response);
print '
';
foreach ($response['ResultSet']['Result'] as $key => $term) {
print '
- ' . $term . '
';
}
print '
';
} else {
print '
';
}
