Skip to content

Instantly share code, notes, and snippets.

@ha1t
Created September 2, 2014 07:58
Show Gist options
  • Save ha1t/e5211256fb2aeb4141c5 to your computer and use it in GitHub Desktop.
Save ha1t/e5211256fb2aeb4141c5 to your computer and use it in GitHub Desktop.
指定URLからfeedを探す
<?php
/**
* 指定URLからfeedを探す
*
*/
header('Content-Type: text/html; charset=UTF-8');
function discover($url)
{
$api_url = 'http://rpc.reader.livedoor.com/feed/discover?format=json';
$api_url .= '&url=' . urlencode($url);
$result = file_get_contents($api_url);
return json_decode($result, true);
}
if ($_POST['url']) {
$result = discover($_POST['url']);
var_dump($result);
foreach ($result as $feed) {
echo "<br /><a href=\"{$feed['feedlink']}\">{$feed['title']}</a>";
}
}
?>
<html>
<body>
<form method="post">
<input type="text" name="url" value="" />
<input type="submit" value="discover" />
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment