Jump to content
cliv

Ajutor RSS Feed in php?

Recommended Posts

Nu sunt programator de php...insa acum ceva timp am incropit un script cu care preluam feed-ul RSS de pe agerpress de la adresa:

Agerpress RSS

 

... acum s-a schimbat ceva si nu mai functioneaza.

Poate ma ajuta cineva.

Codul este urmatorul:

<?php
	setlocale(LC_ALL, array('ro_RO.ISO8859-1', 'ro_RO.ISO-8859-1', 'ro', 'ro_RO', 'rom', 'romanian'));
	$xml=simplexml_load_file("https://www.agerpres.ro/home.rss"); 

	
    $cnt = count($xml->channel->item); 
    $count = 10;  //Numarul de stiri afisate	
	
	for($i=0; $i<$cnt; $i++) { 
		$url = $xml->channel->item[$i]->link; 
		$titlu = $xml->channel->item[$i]->title; 
		$data = $xml->channel->item[$i]->pubDate; 
		$imagine = $xml->channel->item[$i]->description->img->_src; 
		$content = $xml->channel->item[$i]->description->__text; 

		if($count > 0){ 	
			$date = date('d.m.Y - H:i', strtotime($data));

			echo '<div>';	
				echo '<div>';
					echo '<img src='.$imagine.' alt="">';
				echo '</div>';
					
				echo '<h4><a>'.$titlu.'</a></h4>';
								
				echo '<div>';
					echo '<span>publicat la '.$date.'</span>';
				echo '</div>';
								
				echo '<p>'.$content.'</p>';
					
				echo '<a href="'.$url.'" >Citeşte</a>';
			echo '</div>';					
		} 
		
		$count--; 
	}
?>

Multumesc...

 

 

Link to post
Share on other sites
  • Active Members
1 hour ago, n3curatu said:

ai putea sa faci chestia asta asta cu javascript , si cand intra userul sa faci request in numele lui si dupa sa ai un ajax catre trimita raspunsul la tine in server si dupa o verificare daca ai articolul sau nu in db 

 

Same Origin Policy

Edited by dancezar
  • Upvote 2
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...