Generating rss stream (xml php)

 

The goal is to create a xml file to display rss stream.
Data 'll be input in a flash movie which sends them to a php script as xml document.
After parsing the document to fix up an attribute problem and french accents, a xml file 'll be created.
At last, your browser 'll display (for example) something like :

flux RSS

The xml file content is :
( to have best reading it has been displayed as tree )

flux RSS

Obviously, it's an example 'cause more nodes could be used : image, guid, ....
This example doesn't concern a newbye because it needs a good understanding. So I do not expand the building objects methodology.
The different stages are gonna describe right now.

Creating Objects

1 - Set up movie size 800x600. Any background color.
Frame rate = 25.

2 - We need to build the following dialog box :

boite de dialogue flux rss

This box has been made with : ( see tree )

- a label ( name : Génération flux rss ) Arial 16 , w 160, h 20, _x=400 _y=20
- a label ( name : Titre ) Arial 16 , w 41, h 18, _x=15 _y=55
- a label ( name : Url ) Arial 16 , w 33, h 18, _x=15 _y=80
- a label ( name : Description ) Arial 16 , w 88, h 18, _x=15 _y=105
- an input field ( name : titre0_txt , type : Input, var : title0, target coché )
_x=150 _y=55 w=357 h=18
Click the 5th icon to get a framed background.
- an input field ( name : url0_txt , type : Input, var : url0, target coché )
_x=150 _y=80 w=357 h=18
Click the 5th icon to get a framed background.
- an input field ( name : descr0_txt , type : Input, var : descr0, target coché )
_x=150 _y=190 w=555 12 lignes
Click the 5th icon to get a framed background.
- a line
- a label ( name : Titre ) Arial 16 , w 41, h 18, _x=15 _y=230
- a label ( name : Url ) Arial 16 , w 33, h 18, _x=15 _y=255
- a label ( name : Catégorie ) Arial 16 , w 90, h 18, _x=15 _y=280
- a label ( name : Description ) Arial 16 , w 89, h 18, _x=15 _y=305
- an input field ( name : titre1_txt , type : Input, var : title1, target coché )
_x=150 _y=230 w=357 h=18
Click the 5th icon to get a framed background.
- an input field ( name : url1_txt , type : Input, var : url1, target coché )
_x=150 _y=255 w=357 h=18
Click the 5th icon to get a framed background.
- an input field ( name : cat1_txt , type : Input, var : cat1, target coché )
_x=150 _y=280 w=357 h=18
Click the 5th icon to get a framed background.
- an input field ( name : descr1_txt , type : Input, var : descr1, target coché )
_x=150 _y=390 w=555 12 lignes
Click the 5th icon to get a framed background.
- a line
- a label ( name : Titre ) Arial 16 , w 41, h 18, _x=15 _y=430
- a label ( name : Url ) Arial 16 , w 33, h 18, _x=15 _y=455
- a label ( name : Catégorie ) Arial 16 , w 90, h 18, _x=15 _y=480
- a label ( name : Description ) Arial 16 , w 89, h 18, _x=15 _y=505
- an input field ( name : titre2_txt , type : Input, var : title2, target coché )
_x=150 _y=430 w=357 h=18
Click the 5th icon to get a framed background.
- an input field ( name : url2_txt , type : Input, var : url2, target coché )
_x=150 _y=455 w=357 h=18
Click the 5th icon to get a framed background.
- an input field ( name : cat2_txt , type : Input, var : cat2, target coché )
_x=150 _y=480 w=357 h=18
Click the 5th icon to get a framed background.
- an input field ( name : descr2_txt , type : Input, var : descr2, target coché )
_x=150 _y=590 w=555 12 lignes
Click the 5th icon to get a framed background.
- a button ( name : gen_btn , target coché ) _x=651 _y=40 w=150 h=22
- a dynamic text ( name : msg_txt, type : dynamic, var message, target coché )
_x=530 _y=60 w=268 h=20

Script animation

In Scene_1, we set a function to make date. English format : yyyy-mm-dd
Enter script in Scene_1 :

Remark :
SwishMax2 only supports AS2. Thus, the following code is obsolete for the last Flash release, XML AS2 class has been renamed XMLdocument in AS3 for compatibility reasons.

Enter script in button gen_btn :

rssXML object, with data["xml"], is used to send a xml document to a php script named generate.php on the server.
The php script ( see further ) sends back a xml document parsed by ReplyXML object.
This function switches the user depending on REPLY node attributes.
If xml text is <REPLY STATUS="OK" /> STATUS attribute is OK and success message 'll be displayed.
If xml text is <REPLY STATUS="FAILURE" /> STATUS attribute is FAILURE and failure message 'll be displayed.

script PHP generate

With your favourite text editor, enter the following code and save it as generate.php.

Et voilà, that's it !

( See also topic PHP of this site )

 


Si vous aimez le site

 

Select a language if you need :


Page chargée en 0.004 sec.

Dernière Modification : Mer 25 Janvier 2017 8:56
Copyright © 1999-2017 Jean-Paul Molina Tous droits réservés.

to Google