Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Poszukuję skryptu do wyświetlania newsów w innych domenach.
grzesgrzes
post 24.05.2003, 21:27:49
Post #1





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 25.03.2003

Ostrzeżenie: (0%)
-----


Niektóre serwisy udostępniają taką usługę, że można pobrać od nich kod i można na swojej stronie mieć bieżące newsy ukazujące się w tych serwisach.

Czy może ktoś zna takie skrypty, dzięki którym można udostępnić newsy innym domenom i stronom internetowym?

Grzegorz
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 9)
Jabol
post 24.05.2003, 21:30:12
Post #2





Grupa: Przyjaciele php.pl
Postów: 1 467
Pomógł: 13
Dołączył: 22.02.2003

Ostrzeżenie: (0%)
-----


możesz to zrobić w SOAP. poszukaj bo gdzieś o tym było na forum, a z innych linków polecam link do empiku po jakiś stary software 2 o webmasterstwie, albo w3c.
Go to the top of the page
+Quote Post
Seth
post 24.05.2003, 21:33:08
Post #3





Grupa: Przyjaciele php.pl
Postów: 2 335
Pomógł: 6
Dołączył: 7.03.2002

Ostrzeżenie: (0%)
-----


SOAP sluzy raczej do innych zastosowan (chociaz i takie mozna zastosowac.)
Natomiast do tego sluzy RSS
Go to the top of the page
+Quote Post
Cudi
post 24.05.2003, 22:16:52
Post #4


Administrator planeta/IRC


Grupa: Przyjaciele php.pl
Postów: 385
Pomógł: 0
Dołączył: 19.04.2003
Skąd: Zabrze

Ostrzeżenie: (0%)
-----


Można skorzystać równierz z JS, potem user wstawia tylko znacznik SCRIPT z SCR do pliku php, w którym jest skrypt JS generowany przez php.
Go to the top of the page
+Quote Post
grzesgrzes
post 24.05.2003, 22:25:55
Post #5





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 25.03.2003

Ostrzeżenie: (0%)
-----


Jeśli chodzi o JavaScript -skąd można by taki skrypt pobrać?
Go to the top of the page
+Quote Post
Cudi
post 24.05.2003, 22:29:00
Post #6


Administrator planeta/IRC


Grupa: Przyjaciele php.pl
Postów: 385
Pomógł: 0
Dołączył: 19.04.2003
Skąd: Zabrze

Ostrzeżenie: (0%)
-----


Wystarczy skorzystać w JS z document.write i napisać odpowiedni kod php który wygeneruje to co ma być pokazane. Gdzie znaleźć gotowca nie wiem...
Go to the top of the page
+Quote Post
Wankster
post 25.05.2003, 00:38:22
Post #7





Grupa: Zarejestrowani
Postów: 208
Pomógł: 0
Dołączył: 19.04.2003

Ostrzeżenie: (0%)
-----


A tu znaleziony przezemnie parser RSSów i ładnie przerobiony[php:1:116733c485]<?php

if ( IsSet( $_GET['RSS'] ) && ereg("http://", $_GET['RSS'] ) )
{
$rss_file = $_GET['RSS'];
}
else
{
$rss_file = 'http://www.php.net/news.rss';
}

$rss_files = array(
'http://www.php.net/news.rss',
'http://www.sitepoint.com/rss.php',
'http://www.devshed.com/Other_Stuff/Syndication/devshedrss.xml'
// '',
);

print '<p>Inne pliki RSS:<br />';
foreach ( $rss_files AS $_rss_file )
{
print '&&&+ <a href="?RSS=' . $_rss_file . '">' . $_rss_file . '</a><br />' . "n";
}
print '</p>- - - - - - - - - - - -<br />';

class RSSParser
{
var $insideitem = false;
var $tag = "";
var $title = "";
var $description = "";
var $link = "";
var $image = "";
var $date = "";

function RSSParser( $rss_file )
{
$xml_parser = xml_parser_create();

xml_set_object( $xml_parser, &$this );
xml_set_element_handler( $xml_parser, "startElement", "endElement" );
xml_set_character_data_handler( $xml_parser, "characterData" );

$fp = fopen( $rss_file, "r" )
or die( "Error reading RSS data." );

while ( $data = fread( $fp, 4096 ) )
xml_parse( $xml_parser, $data, feof( $fp ) )
or die( sprintf( "XML error: %s at line %d",
xml_error_string( xml_get_error_code( $xml_parser ) ),
xml_get_current_line_number( $xml_parser ) ) );

fclose( $fp );

xml_parser_free( $xml_parser );
} // end function 'RSSParser'

function startElement( $parser, $tagName, $attrs )
{
if ( $this->insideitem )
{
$this->tag = $tagName;
}
else if ( $tagName == "ITEM" )
{
$this->insideitem = true;
} // end if... else if...
} // end function 'startElement'

function endElement( $parser, $tagName )
{
if ( $tagName == "ITEM" )
{
// Printing image if exists
if ( !( empty( $this->image ) ) )
{
$size = GetImageSize( $this->image );

printf( "<img src="%s" width="%s" height="%s" border="0" align="left" valign="top">",
trim( $this->image ), $size[0], $size[1] );

$size = '';
} // end if...

// Printing date
if ( !( empty( $this->date ) ) )
{
printf( "<p><b>%s</b> | ",
trim( $this->date ) );
}
else
{
print '<p>';
} // end if... else...

// Printing link
printf( "<b><a href="%s" target="_blank">%s</a></b></p>",
trim( $this->link ), htmlspecialchars( trim( $this->title ) ) );

// Printing description
printf( "<p>%s</p>",
htmlspecialchars( trim( $this->description ) ) );

$this->title = "";
$this->description = "";
$this->link = "";
$this->image = "";
$this->date = "";
$this->insideitem = false;
} // end if...
} // end function 'endElement'

function characterData( $parser, $data )
{
if ( $this->insideitem )
{
switch ( $this->tag )
{
case "TITLE":
$this->title .= $data;
break;

case "DESCRIPTION":
$this->description .= $data;
break;

case "LINK":
$this->link .= $data;
break;

case "IMAGE":
$this->image .= $data;
break;

case "DATE":
$this->date .= $data;
break;

case "DC:DATE":
$this->date .= $data;
break;
} // end switch
} // end if...
} // end function 'characterData'
} // end class 'RSSParser'

$ParseRSS = new RSSParser( $rss_file );

?>[/php:1:116733c485]
Demo: http://dev.webcenter.net.pl/RSSParser.php
Go to the top of the page
+Quote Post
grzesgrzes
post 25.05.2003, 22:24:24
Post #8





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 25.03.2003

Ostrzeżenie: (0%)
-----


Wankster - bardzo dziękuję za pomoc. Spróbuję z tympowalczyc
Go to the top of the page
+Quote Post
grzesgrzes
post 28.05.2003, 19:10:06
Post #9





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 25.03.2003

Ostrzeżenie: (0%)
-----


Jak ten skrypt dostosować, aby ludzie bez php mogli go użyć.
Go to the top of the page
+Quote Post
Jabol
post 28.05.2003, 20:00:20
Post #10





Grupa: Przyjaciele php.pl
Postów: 1 467
Pomógł: 13
Dołączył: 22.02.2003

Ostrzeżenie: (0%)
-----


każdy język, który obsługuje XML (czyli chyba wszystkie dzisiaj) powinien to obsłużyć.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 11:45