Load File containing URLs

How do I load a file containing 10 video URL’s stored on a web location?

I want to update the list as need be and in the app display them either in a split view or scrollable view which ever is doable.

There are a few different approaches in mind but after some advice on the best one.

First things first, how do I read the file?

http://developer.xojo.com/xojo-net-httpsocket

A little hard to understand but having watched the video and looked at a few examples, I get an runtime exception when it tries to convert my file. Does the file have to be JSON which most of the example refer to?

http://www.sallyfitz.com/AppVideoClips.txt

// We convert the returned content (MemoryBlock) to a Text
Dim buffer As Text = TextEncoding.UTF8.ConvertDataToText(Content)

I would recommend using the old framework for now, it’s easier to deal with.

http://documentation.xojo.com/index.php/HTTPSocket to download the text file as a string, you can then parse the string with RegEx to get the names and urls in a way that you want them.

[quote=288625:@Tim Parnell]I would recommend using the old framework for now, it’s easier to deal with.
[/quote]

You can’t. It does not exist for iOS.

What is the exact error ?

It should work doing this (replace the URL with that of the file you want to get) :

Dim outputFile As Xojo.IO.FolderItem = Xojo.IO.SpecialFolder.Documents.Child("mylistofURLs.txt") mySocket.Send("GET", "http://127.0.0.1:8080/GetData", outputFile)

Then use the last example at http://developer.xojo.com/xojo-io-textinputstream to load back into your program.

Oh shoot, didn’t even notice.

Still no luck.
I added a Class (MyHTTPsocket) with the super ‘xojo.net.HTTPSocket’

I put the following in the Open event
Dim outputFile As Xojo.IO.FolderItem = Xojo.IO.SpecialFolder.Documents.Child(“mylistofURLs.txt”)
MyHTTPsocket.Send(“GET”, “http://www.sallyfitz.com/AppVideoClips.txt”, outputFile)

Error
There is more than one item with this name and it is not clear to which it refers

[quote=288679:@Martin Fitzgibbons]Error
There is more than one item with this name and it is not clear to which it refers[/quote]
That error is also thrown if there is no method of that name which matches that signature. When this error appears, what is highlighted?

[quote=288679:@Martin Fitzgibbons]Still no luck.
I added a Class (MyHTTPsocket) with the super ‘xojo.net.HTTPSocket’

I put the following in the Open event
Dim outputFile As Xojo.IO.FolderItem = Xojo.IO.SpecialFolder.Documents.Child(“mylistofURLs.txt”)
MyHTTPsocket.Send(“GET”, “http://www.sallyfitz.com/AppVideoClips.txt”, outputFile)

Error
There is more than one item with this name and it is not clear to which it refers[/quote]

Adding the class is not enough. You want to drag an instance of it onto the view.

Then use the instance, which most probably will be named myHTTPSocket1.

That said, I just tried, and mylistofURLs.txt ends up with mylistofURLs.txt created but empty (zero bytes). I tried to add a Safari user agent header, it does not do the trick.

Ok I am at the same spot, it loads but is empty

What does Safari have to do with the contents of the file?
‘I tried to add a Safari user agent header, it does not do the trick.’

[quote=288684:@Martin Fitzgibbons]Ok I am at the same spot, it loads but is empty

What does Safari have to do with the contents of the file?
‘I tried to add a Safari user agent header, it does not do the trick.’[/quote]

Some sites do not honor requests from certain unsupported browsers. An HTTPSocket is not a browser. Setting the user agent makes it look like Safari.

ok thanks.

That still leaves the problem of the socket seeing the file ok but not loading any data.

The file is ok if you drop the link on Safari it displays it fine??

@Martin Fitzgibbons: Give this a try: https://xojo.io/dc007f380a5c

That pulls your text file and just displays it - but you could use the contents in other ways, of course.

A few quick notes:

I added a plist file to the project, which is used to configure NSAppTransportSecurity. This allows the app to GET the file via standard HTTPS.

The PageReceived method of the HTTP socket converts the response using:

Dim TextResponse As Text = Xojo.Core.TextEncoding.UTF16LittleEndian.ConvertDataToText(Content)

I hope this helps. Let me know if you have any questions.

Brilliant thanks Tim and everyone else who expanded my knowledge :slight_smile: