Created
September 2, 2014 07:58
-
-
Save ha1t/e5211256fb2aeb4141c5 to your computer and use it in GitHub Desktop.
指定URLからfeedを探す
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 | |
/** | |
* 指定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