Sample Code: A Corona-powered business app with Google Blogger

Ok I’ve tried everything. Both with Wordpress(rss) and with Google Blogger(atom). I keep getting that same error. The URLs take me straight to the blog. Still don’t know how to get this working. :frowning:

<jeppy7>: The threshold question is whether the error is in your app or the remote RSS feed. Fortunately there is an easy way to test using W3C’s validator: http://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Fsacsportsblog.wordpress.com%2F%3Ffeed%3Drss

And it turns out that the sacsportblog site is valid RSS. Therefore the error is in your code. (There is an outside chance – a third possibility, in other words – that there’s a redirect, which you can check by saving to a static file on a site that you control without redirects.)

If what you found online is insufficient or doesn’t work, you may have to write your own RSS parser. I’ve written my own RSS/Atom feed generator in the past, and it isn’t too painful; if you’re dealing with a single valid RSS feed, parsing it should be pretty straightforward. You may want to buy one of the books on Lua programming.

I was starting to come to that conclusion myself as well. Thanks corona273, and much thanks to you Rob Miracle for all your help!

There are no meta and head tags in the feed:

\<?xml version="1.0" encoding="UTF-8"?\>\<rss version="2.0" &nbsp;&nbsp; &nbsp;xmlns:content="http://purl.org/rss/1.0/modules/content/" &nbsp;&nbsp; &nbsp;xmlns:wfw="http://wellformedweb.org/CommentAPI/" &nbsp;&nbsp; &nbsp;xmlns:dc="http://purl.org/dc/elements/1.1/" &nbsp;&nbsp; &nbsp;xmlns:atom="http://www.w3.org/2005/Atom" &nbsp;&nbsp; &nbsp;xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" &nbsp;&nbsp; &nbsp;xmlns:slash="http://purl.org/rss/1.0/modules/slash/" &nbsp;&nbsp; &nbsp;xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84\_pos#" xmlns:media="http://search.yahoo.com/mrss/" &nbsp;&nbsp; &nbsp;\> \<channel\> &nbsp;&nbsp; &nbsp;\<title\>sacsportsblog\</title\> &nbsp;&nbsp; &nbsp;\<atom:link href="https://sacsportsblog.wordpress.com/feed/" rel="self" type="application/rss+xml" /\> &nbsp;&nbsp; &nbsp;\<link\>https://sacsportsblog.wordpress.com\</link\> &nbsp;&nbsp; &nbsp;\<description\>\</description\> &nbsp;&nbsp; &nbsp;\<lastBuildDate\>Tue, 14 Apr 2015 04:54:07 +0000\</lastBuildDate\> &nbsp;&nbsp; &nbsp;\<language\>en\</language\> &nbsp;&nbsp; &nbsp;\<sy:updatePeriod\>hourly\</sy:updatePeriod\> &nbsp;&nbsp; &nbsp;\<sy:updateFrequency\>1\</sy:updateFrequency\> &nbsp;&nbsp; &nbsp;\<generator\>http://wordpress.com/\</generator\> \<cloud domain='sacsportsblog.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' /\> \<image\> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\<url\>https://s2.wp.com/i/buttonw-com.png\</url\> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\<title\>sacsportsblog\</title\> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\<link\>https://sacsportsblog.wordpress.com\</link\> &nbsp;&nbsp; &nbsp;\</image\> &nbsp;&nbsp; &nbsp;\<atom:link rel="search" type="application/opensearchdescription+xml" href="https://sacsportsblog.wordpress.com/osd.xml" title="sacsportsblog" /\> &nbsp;&nbsp; &nbsp;\<atom:link rel='hub' href='https://sacsportsblog.wordpress.com/?pushpress=hub'/\> &nbsp;&nbsp; &nbsp;\<item\> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\<title\>Welcome to my blog\</title\> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\<link\>https://sacsportsblog.wordpress.com/2015/04/14/welcome-to-my-blog-3/\</link\> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\<comments\>https://sacsportsblog.wordpress.com/2015/04/14/welcome-to-my-blog-3/#comments\</comments\> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\<pubDate\>Tue, 14 Apr 2015 03:22:22 +0000\</pubDate\> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\<dc:creator\>\<![CDATA[jeppy7]]\>\</dc:creator\> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\<category\>\<![CDATA[Uncategorized]]\>\</category\> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\<guid isPermaLink="false"\>http://sacsportsblog.wordpress.com/?p=14\</guid\> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\<description\>\<![CDATA[Hey sports fans!!! Welcome to my new Sacramento sports page. This blog is a place for Sac sports fans to come and see whats happening in the Sacramento, and all over the world. I plan to integrate some of my sporting interests as well. The mobile app version is already near completion. So watch for [&#8230;]\<img alt="" border="0" src="https://pixel.wp.com/b.gif?host=sacsportsblog.wordpress.com&#038;blog=89331984&#038;post=14&#038;subd=sacsportsblog&#038;ref=&#038;feed=1" width="1" height="1" /\>]]\>\</description\> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\<content:encoded\>\<![CDATA[\<p\>Hey sports fans!!! Welcome to my new Sacramento sports page. This blog is a place for Sac sports fans to come and see whats happening in the Sacramento, and all over the world. I plan to integrate some of my sporting interests as well. The mobile app version is already near completion. So watch for updates! I encourage healthy debates on here, as well as suggestions on new material. I will also try to post important dates, times, and locations/channels of local/popular events. I look forward to everyone&#8217;s inputs!\</p\>\<br /\>&nbsp; \<a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sacsportsblog.wordpress.com/14/"\>\<img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sacsportsblog.wordpress.com/14/" /\>\</a\> \<img alt="" border="0" src="https://pixel.wp.com/b.gif?host=sacsportsblog.wordpress.com&#038;blog=89331984&#038;post=14&#038;subd=sacsportsblog&#038;ref=&#038;feed=1" width="1" height="1" /\>]]\>\</content:encoded\> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\<wfw:commentRss\>https://sacsportsblog.wordpress.com/2015/04/14/welcome-to-my-blog-3/feed/\</wfw:commentRss\> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\<slash:comments\>0\</slash:comments\> &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\<media:content url="https://2.gravatar.com/avatar/e714809a4476639cef5d3be7bc549761?s=96&#38;d=identicon&#38;r=G" medium="image"\> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\<media:title type="html"\>jeppy7\</media:title\> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\</media:content\> &nbsp;&nbsp; &nbsp;\</item\> &nbsp;&nbsp; &nbsp;\</channel\> \</rss\>

<meta> and <head> are HTML tags.  This sounds like you’re hitting a 404 page.

I just ran the project you uploaded.  I changed it back to RSS and I use this as the URL:  https://sacsportsblog.wordpress.com/feed/

Here is the contents of my console log:

Apr 14 18:49:26.583: &nbsp;&nbsp; &nbsp;Copyright (C) 2009-2015&nbsp; C o r o n a&nbsp;&nbsp; L a b s&nbsp;&nbsp; I n c . Apr 14 18:49:26.584: &nbsp;&nbsp; &nbsp;Version: 3.0.0 Apr 14 18:49:26.584: &nbsp;&nbsp; &nbsp;Build: 2015.2599 Apr 14 18:49:26.602: Platform: SM-G900S / x86\_64 / 10.10.3 / Intel HD Graphics 4000 OpenGL Engine / 2.1 INTEL-10.6.20 / 2015.2599 Apr 14 18:49:26.747: Loading project from:&nbsp;&nbsp; ~/Downloads/Sac Sports Blog Apr 14 18:49:26.747: Project sandbox folder: ~/Library/Application Support/Corona Simulator/Sac Sports Blog-AB4341FD906246FF863302C77211CB99 Apr 14 18:49:32.324: create scene Apr 14 18:49:32.326: enter scene Apr 14 18:49:32.578: enter scene Apr 14 18:49:32.579: show&nbsp;&nbsp; &nbsp;sacsportsblog.rss&nbsp;&nbsp; &nbsp;https://sacsportsblog.wordpress.com/feed/ Apr 14 18:49:32.580: entering displayFeed&nbsp;&nbsp; &nbsp;sacsportsblog.rss&nbsp;&nbsp; &nbsp;https://sacsportsblog.wordpress.com/feed/ Apr 14 18:49:32.630: calling processRSSFeed because the feed is avaialble Apr 14 18:49:32.631: Parsing the feed Apr 14 18:49:32.633: Number of items: 14 Apr 14 18:49:32.633: Num stories: 1 Apr 14 18:49:32.633: Got &nbsp;&nbsp; &nbsp;1&nbsp;&nbsp; &nbsp; stories, now show the tableView Apr 14 18:49:32.633: Calling showTableView() Apr 14 18:49:32.634: insert row:&nbsp; 1 [Welcome to my blog] Apr 14 18:49:32.634: row render

It appears to be working to me…

Rob

Can you provide more context?  Do you  have the URL where you downloaded the sample from?  Can you describe what you expect to see and what you are seeing?  (A screenshot could be helpful)…  Are there any errors in your console log?

Rob

First off, I want to thank you for the quick response, and secondly I want to apologize for not posting this in the proper topic area. I found that you have a topic created for this sample code. Despite my best efforts to find it before setting up this topic, it wasn’t discovered until later. 

Ok, the URL I downloaded the sample code from is https://coronalabs.com/blog/2013/10/09/a-look-inside-a-sample-corona-powered-business-app/ 

I made very few changes, such as the title to the menu scene and titles to the menu I.E. - "Corona Blogs -> Blog. No other changes where made besides trying to link to my blog URL through the main.lua.

I tried uploading screenshot image from mail.lua, but forum requires URL, so I used tinypic.com for free image hosting and I got a broken image in this forum.  http://i58.tinypic.com/2yytnut.png  

That should take you to tinypic.com for a picture of the code that refers to my URL in main.lua.

The URL is http://www.sacsportsblog.blogspot.com/ but for Google Blogger it states that the RSS feed URL is http://www.sacsportsblog.blogspot.com/feed/posts/default?alt=rss 

the name of my blog is sacsportsblog.

Here is the error in the Sublime Text console.

show sacsportsblog.rss http://www.sacsportsblog.blogspot.com/feed/posts/default?alt=rss

entering displayFeed sacsportsblog.rss http://www.sacsportsblog.blogspot.com/feed/posts/default?alt=rss

calling processRSSFeed because the feed is avaialble

Parsing the feed

Runtime error

c:\users\jeffrey\desktop\sac sports blog\xml.lua:124: XmlParser: trying to close <c> with <script>

stack traceback:

C: in function ‘error’

c:\users\jeffrey\desktop\sac sports blog\xml.lua:124: in function ‘ParseXmlText’

c:\users\jeffrey\desktop\sac sports blog\xml.lua:154: in function ‘loadFile’

c:\users\jeffrey\desktop\sac sports blog\rss.lua:30: in function ‘feed’

c:\users\jeffrey\desktop\sac sports blog\feed.lua:318: in function ‘processRSSFeed’

c:\users\jeffrey\desktop\sac sports blog\feed.lua:341: in function <c:\users\jeffrey\desktop\sac sports blog\feed.lua:334>

I can provide a zip or compressed file of the files for the app, or just the main.lua if you would like. The only problem is I still can’t figure out how to upload media to the community, and if I did know how would I even be able to upload a zip… Thanks again for your help!

First to post images to the forum, click on the “More Reply Options” beside the “Post” button and there you can upload attachments including images.

I went to the website you linked to and its actually outputting an atom feed, not an RSS 2.0 feed.   Atom is sort of RSS 1.0.  The expected tags though are pretty different.  The code should have both an Atom parser and an RSS parser in there (atom.lua).  You need to require the atom.lua file instead of the rss.lua file at the top and it hopefully will take care of you.

The   ?alt=rss should cause it to use RSS 2.0, but it’s was still outputing Atom content.

Rob

<jeppy7>: If Rob is right, you could set up an App Engine instance to convert Atom to RSS using some of the readily available Python utilities. If you stay under 200-or-so requests a day, it should be free. Or you can parse Atom on the client, of course.

It would be pretty easy to make a simple change to rss.lua that after you ingest the XML, to check the header to see if its an atom or rss 2.0 feed and load in the atom processor instead.

I can’t get to this now, but it would be a good feature.  This is the one thing that hangs people up the most.

Rob

This is very interesting. I’m relatively new to Blogs, but have about a year experience with Corona/lua. I attached the zip containing the program. Unfortunately, I’m still receiving an error. :frowning:

I changed the URL in main.lua to refer to the Google Blogger atom feed (just removed everything after default in address)

I also changed the reference to the rss in feed.lua to atom, which was pre-setup with comments.

Here’s the error:

Runtime error

c:\users\jeffrey\desktop\sac sports blog\xml.lua:124: XmlParser: trying to close <c> with <script>

stack traceback:

C: in function ‘error’

c:\users\jeffrey\desktop\sac sports blog\xml.lua:124: in function ‘ParseXmlText’

c:\users\jeffrey\desktop\sac sports blog\xml.lua:154: in function ‘loadFile’

c:\users\jeffrey\desktop\sac sports blog\atom.lua:28: in function ‘feed’

c:\users\jeffrey\desktop\sac sports blog\feed.lua:318: in function ‘processRSSFeed’

c:\users\jeffrey\desktop\sac sports blog\feed.lua:341: in function <c:\users\jeffrey\desktop\sac sports blog\feed.lua:334>

I don’t see that error, but there is something inconstant between atom.lua and rss.lua.   The rss.lua returns feed.items and atom.lua returns feed.entries.  I would update atom.lua to return feed.items instead.  That will get them returning the same thing.

As for the error above, trying to close <c> with <script> sounds like an invalid feed.  I ran it against a validator and it passed, but that doesn’t mean the story wasn’t fixed between the time you posted it and the time I looked at it.

Rob

After I changed the feed.entries to feed.items, I tried to run it on my friends mac machine. Note: I also have access to macincloud a cloud mac server so I can do it there as well. 

Here is the error that I get:

stack traceback:

/Users/PatrickMoreno/Desktop/Sac Sports Blog/atom.lua:29: in function ‘feed’

/Users/PatrickMoreno/Desktop/Sac Sports Blog/feed.lua:318: in function ‘processRSSFeed’

/Users/PatrickMoreno/Desktop/Sac Sports Blog/feed.lua:341: in function </Users/PatrickMoreno/Desktop/Sac Sports Blog/feed.lua:334>

I believe that the windows simulator was having a little trouble, but I can’t locate the problem now even on a mac machine. I’m using Corona V 2014.2511 if that helps on a mac with OS X Yosemite 10.10.1

Thanks Rob!

Ok I changed the feed.entries to feed.items in atom.lua. I also ran the simulator on a mac machine.

Here is the error I’m getting on the mac machine when I try to run the simulator:

2015-04-13 12:15:14.211 Corona Simulator[5837:507] enter scene

2015-04-13 12:15:14.211 Corona Simulator[5837:507] show sacsportsblog.rss http://www.sacsportsblog.blogspot.com/feed/posts/default

2015-04-13 12:15:14.214 Corona Simulator[5837:507] entering displayFeed sacsportsblog.rss http://www.sacsportsblog.blogspot.com/feed/posts/default

2015-04-13 12:15:14.405 Corona Simulator[5837:507] calling processRSSFeed because the feed is avaialble

2015-04-13 12:15:14.406 Corona Simulator[5837:507] Parsing the feed

2015-04-13 12:15:14.406 Corona Simulator[5837:507] /Users/user92217/Library/Application Support/Corona Simulator/Sac Sports Blog-685AE2C56A13BF52BA42339F6275BD60/Caches/sacsportsblog.rss: No such file or directory

2015-04-13 12:15:14.407 Corona Simulator[5837:507] Runtime error

/Users/user92217/Desktop/Sac Sports Blog/atom.lua:29: attempt to index local ‘myFeed’ (a nil value)

stack traceback:

/Users/user92217/Desktop/Sac Sports Blog/atom.lua:29: in function ‘feed’

/Users/user92217/Desktop/Sac Sports Blog/feed.lua:318: in function ‘processRSSFeed’

/Users/user92217/Desktop/Sac Sports Blog/feed.lua:341: in function </Users/user92217/Desktop/Sac Sports Blog/feed.lua:334>

The URL you are using is bad.  Click on it in your browser and it takes you to a not found page.  The real URL is:

http://sacsportsblog.blogspot.com/feeds/posts/default

It’s a subtle difference, but the “www.” breaks the URL.  Many sites alias www and with just the domain name specified.  It doesn’t look like this site is setup to do that.

Rob

That’s interesting. However, I removed www from the URL in main.lua and I still see the exact same error.

Can you click on the link in my post above?

Yes I can and that’s the address that I have for feedURL in main.lua

The URL’s in the log message above however don’t go to a valid place.  I wonder if there is a redirect going on that’s hosing you.   In the feed.lua file there should be a network.request() call that fetches the file.  It’s returning successfuly, but not with a valid feed.  Perhaps you can put some logging in the network.request()'s listener to dump some of the event data and see what’s going on.

Rob

Well it may be easier to try a different blog that’s more accessible. I just recently created the sacsportsblog, and it’s not like I would lose a lot of followers if I switched to one that worked with this Corona app. Do you have a recommendation for a free blog host that would work with the app? By free I mean one that provides a domain, since I’m doing this for educational purposes.

Wordpress works pretty well, but I don’t know if Wordpress.com will let you have your own domain for free or not.  But hosting accounts are pretty cheap.  People like Hostgator can be as cheap as $4 a month.