Advertisement
ipsBruno

(PHP) links/titulos aleátorios em blogspot - posts random

Sep 15th, 2012
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  /*
  5.  *  Copyright (c) 2012 [iPs]TeaM
  6.  *  Bruno da Silva (email@brunodasilva.com)
  7.  *  Pegar links e títulos de post aleatoriamente em blogspot
  8.  *
  9.  * www.brunodasilva.com
  10.  * www.ips-team.forumeiros.com
  11. */
  12.  
  13.  
  14.  
  15.     $url = $_GET['url'];
  16.    
  17.     $url .= "/feeds/posts/default";
  18.  
  19.     $xml = simplexml_load_file($url);
  20.  
  21.     $total =(int) $xml->children('openSearch', true)->totalResults;
  22.      
  23.     $aleatorio = mt_rand ( 25, $total );
  24.  
  25.     pegarLigações( ($aleatorio - 25), $aleatorio )  ;
  26.  
  27.     function pegarLigações( $inicio, $fim )  
  28.     {
  29.         $url = $_GET['url'];
  30.    
  31.         $url .= "/feeds/posts/default";
  32.  
  33.         $url .= "?start-index=$inicio&amp;max-results=$fim";
  34.  
  35.         $xml = simplexml_load_file($url);
  36.  
  37.    
  38.         for ($i = 0; isset( $xml->entry[$i]->title) ; $i ++) {
  39.  
  40.             echo $xml->entry[$i]->title;
  41.             echo $xml->entry[$i]->link[4]["href"] . "<br/>";
  42.  
  43.         }
  44.  
  45.         return true;
  46.     }
  47.    
  48.  
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement