[solved] Download/Display Text

Hello! I am trying to download and display text from my server. Basically, I would have “Brother, can you spare a dime?” written in a file called “update.txt” on my server, and I’d like to display this text on my device.

What would be the easiest way to do this? I’ve looked through some of the downloading information and I’m not quite understanding it.

Thanks in advance! [import]uid: 30399 topic_id: 11208 reply_id: 311208[/import]

The below code does the trick. Of course, change the “yourdomainhere” address in YOUR code to reflect your server’s address.

Remember, it’s event based so your program’s other code will be executing before the network response in some cases.

Checky:

local txt=display.newText('More text should appear soon....',10,10)  
  
function networkListener( event )  
 -- event.response is the actual contents of the text   
 -- file I threw on my server.  
 local more=display.newText(event.response,10,30)  
end  
  
network.request( "http://www.yourdomainhere.com/stuff/update.txt", "GET", networkListener )  

Also, you have the option of going totally nuts with all sorts of PHP scripts and what-not to return whatever text (http://php.about.com/od/finishedphp1/p/random_quote.htm)
you’ll need, graphics too!! [import]uid: 11636 topic_id: 11208 reply_id: 40658[/import]

Thank you SO much. That is so simple, I feel a bit stupid. But I get it now.

Awesome. I have it working as needed. Again, thanks a lot! [import]uid: 30399 topic_id: 11208 reply_id: 40684[/import]

Don’t be silly! You don’t learn if you don’t ask!! :slight_smile: Now remember, the HTTP request function can go a long way, from displaying text, to updating your in-app databases with the latest, greatets info. For my project, I’m going to use it to (hopefully) tweak ship combat stats, etc. so the user won’t have to download whole updates.

Oh and think about it, you can have a cool RSS-ish feed from your server to your app with news, etc.

Pretty cool!!

Don’t forget to share with the community what you’ve done, and don’t hesitate to ask for help. The Corona community seems pretty friendly!

-Mario

PS Love your name’s play on words too! Killin’ me! [import]uid: 11636 topic_id: 11208 reply_id: 40685[/import]

Yeah, I plan on doing some of the same. I like the idea of remotely updating the software by having it sync into the server.

As for the name, I have to admit that it’s my old World of Warcraft name. But I loved it so much I had to bring it over. [import]uid: 30399 topic_id: 11208 reply_id: 40954[/import]

Hi.

I have a problem with network.request.

please help me, my app work on the simulator but not in the phone.

i dont understand what happen.

[import]uid: 12275 topic_id: 11208 reply_id: 54798[/import]

my hint:

open a new thread for it, take a good subject, explain as exactly as possible, what you do or try to do, maybe show the important part of the code… [import]uid: 70114 topic_id: 11208 reply_id: 54817[/import]