Come posso estrarre l'ultimo post di un feed atom (blogger) e visualizzarlo con PHP?
Grazie
Come posso estrarre l'ultimo post di un feed atom (blogger) e visualizzarlo con PHP?
Grazie
la prima cosa che mi viene in mente è che potresti leggere il feed del blog:
e poi potresti recuperarti l'ultimo elemento inserito:Codice PHP:
$feedUrl = 'www.tuoblog.com/feed';
$rawFeed = file_get_contents($feedUrl);
$xml = new SimpleXmlElement($rawFeed);
Codice PHP:
$xml->channel->item[0]
Mi da questi errori
codice:Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configurationcodice:Warning: file_get_contents(www.sito.it/feed) [function.file-get-contents]: failed to open stream: no suitable wrapper could be foundcodice:Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML'codice:Stack trace: #0 : SimpleXMLElement->__construct('') #1 {main} thrown
Il problema leggendo il primo warning è chiaro, non puoi usare file_get_content, il server non ti permette l'accesso ai file.
prova così:
Codice PHP:
$url = "feed.xml";
$xml = simplexml_load_file($url);
Mi restituisce questo errore:
codice:Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity ""
Il motivo penso sia lo stesso di file_get_contents, se non hai accesso al file nessuna funzione che prova a leggerlo andrà a buon fine.
Quindi non posso leggere da un feed di blogger?![]()
potresti postare il link del feed?