Last active
April 9, 2020 15:41
-
-
Save jonathands/da8039fc5864a625079e4f8a28abf318 to your computer and use it in GitHub Desktop.
RSS para HTML
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
| <div id="conteudo_semanal" class="conteudo_semanal"> | |
| <?php | |
| //COLE O ENDEREÇO DO RSS DE SEU INFORMATIVO ABAIXO, AS ENTRE ASPAS DUPLAS | |
| $endereco_do_rss = "*SUBSTITUA PELO ENDEREÇO RSS EM SUA ÁREA RESTRITA"; | |
| echo "<!-- $endereco_do_rss -->"; | |
| $invalidurl = false; | |
| if(@simplexml_load_file($endereco_do_rss)){ | |
| $feeds = simplexml_load_file($endereco_do_rss); | |
| }else{ | |
| $invalidurl = true; | |
| echo "<h2>Endereço do semanal errado.</h2>"; | |
| } | |
| $i=0; | |
| if(!empty($feeds)){ | |
| $site = $feeds->channel->title; | |
| $sitelink = $feeds->channel->link; | |
| echo "<img src='{$feeds->channel->image->url}'/>"; | |
| echo "<h1>".$site."</h1>"; | |
| foreach ($feeds->channel->item as $item) { | |
| $title = $item->title; | |
| $link = $item->link; | |
| $description = $item->description; | |
| $postDate = $item->pubDate; | |
| $pubDate = date('d/m/Y',strtotime($postDate)); | |
| ?> | |
| <div class="post"> | |
| <div class="post-head"> | |
| <h2><a class="feed_title" href="<?php echo $link; ?>"><?php echo $title; ?></a></h2> | |
| <span><?php echo $pubDate; ?></span> | |
| </div> | |
| <div class="post-content"> | |
| <?php echo implode(' ', array_slice(explode(' ', $description), 0, 20)) . "..."; ?> <a href="<?php echo $link; ?>">Ler mais</a> | |
| </div> | |
| </div> | |
| <?php | |
| $i++; | |
| } | |
| }else{ | |
| if(!$invalidurl){ | |
| echo "<h2>Nenhuma notícia encontra</h2>"; | |
| } | |
| } | |
| ?> | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment