grabbing rss or other type of feeds within lift

4 views
Skip to first unread message

Mark Essel

unread,
Jun 29, 2009, 10:33:41 PM6/29/09
to Lift
trying to conjure up a similar functioning piece of code in scala to
grab my status from twitter.

(php)
$username = "victusfate";
$feed = "http://search.twitter.com/search.atom?q=from:" . $username .
"&rpp=1";
//echo $feed;
function parse_feed($feed) {
$stepOne = explode("<content type=\"html\">", $feed);
$stepTwo = explode("</content>",$stepOne[1]);
$tweet = $stepTwo[0];
$tweet = str_replace("&lt;", "<", $tweet);
$tweet = str_replace("&gt;", ">", $tweet);
return $tweet;
}
$twitterFeed = file_get_contents($feed);
echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes
($suffix);

(.scala file)
var username = "victusfate"
var feed = "http://search.twitter.com/search.atom?q=from:" +
username + "&rpp=1"
<span>{ feed }</span>

stuck here tried Rome, and various other feed fetching libraries
without much luck (very new to the language and setup)

Timothy Perrett

unread,
Jun 30, 2009, 4:16:47 AM6/30/09
to Lift
mark,

take a look at: http://is.gd/1iUJN

That should provide you some guidance. I notice from your example your
trying to parse the twitter feed? Perhaps if you want to do something
with twitter you should consider a proper twitter api lib:
http://code.google.com/p/java-twitter/

Cheers, Tim

Mark Essel

unread,
Jun 30, 2009, 9:37:23 AM6/30/09
to Lift
Thanks Tim. will definitely check out the lib (not sure of licensing
issues, plan on developing a product with it)

David Pollak

unread,
Jun 30, 2009, 10:09:10 AM6/30/09
to lif...@googlegroups.com
Personally, I'd use Scala's XML parsing to parse the feed... skip the external library.

You may also want to look at the ESME code http://incubator.apache.org/esme/  There's an RSS reader and a Twitter poller in there.  The code is Apache 2.0 license, so you can use it without any license-related concerns.
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

TylerWeir

unread,
Jun 30, 2009, 10:19:20 AM6/30/09
to Lift
I remembered this came up a long time ago as well:

http://groups.google.com/group/liftweb/browse_frm/thread/e58ba45f7c0a111d/20344ff205393ec7?lnk=gst&q=twitter+front#20344ff205393ec7




On Jun 30, 10:09 am, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> Personally, I'd use Scala's XML parsing to parse the feed... skip the
> external library.
> You may also want to look at the ESME codehttp://incubator.apache.org/esme/There's an RSS reader and a Twitter
> Beginning Scalahttp://www.apress.com/book/view/1430219890

Mark Essel

unread,
Jul 1, 2009, 5:16:08 PM7/1/09
to Lift
Thanks David. I'm going with some direct calls for simplicity (along
the path you suggested).
along the lines of:

val rssFeed = XML.load( (new URL
(feedUrl)).openConnection.getInputStream )

One more oddity, I'm getting problems compiling normal scala code but
I can build lift projects (with scala inside them).

Something that I need to add in the config file like a path to the
scala binaries? (installed it in windows default spot)
for netbeans.conf
the netbeans_default_options var, adding
-J-Dscala.home=SCALA_HOME
where's SCALA_HOME supposed to point to?
I tried:
-D\"c:\Users\Dude Jones\.netbeans\6.7rc3\scala\scala-2.7.3.final\\"
where the binaries are no luck

Getting the error:
init:
deps-jar:
Compiling 1 source file to C:\Mark\misc\EntrepreneurInfo
\IntelligentAdvertisingSoftware\testo\build\classes
Could not connect to compilation daemon.
org.netbeans.core.execution.ExitSecurityException: Exit from within
execution engine, normal
at org.netbeans.core.execution.SecMan.checkExitImpl
(SecMan.java:85)
at org.netbeans.core.execution.SecMan$PrivilegedCheck.run
(SecMan.java:160)
at java.security.AccessController.doPrivileged(Native Method)
at org.netbeans.core.execution.SecMan$PrivilegedCheck.check
(SecMan.java:175)
at org.netbeans.core.execution.SecMan$PrivilegedCheck.checkExit
(SecMan.java:170)
at org.netbeans.core.execution.SecMan.checkExit(SecMan.java:
69)
at org.netbeans.TopSecurityManager.checkExit
(TopSecurityManager.java:149)
at java.lang.Runtime.exit(Runtime.java:88)
at java.lang.System.exit(System.java:904)
at scala.Predef$.exit(Predef.scala:81)
at scala.tools.nsc.CompileSocket.fatal(CompileSocket.scala:53)
at scala.tools.nsc.CompileSocket.getPort(CompileSocket.scala:
175)
at scala.tools.nsc.CompileSocket.getsock$1(CompileSocket.scala:
206)
at scala.tools.nsc.CompileSocket.getOrCreateSocket
(CompileSocket.scala:227)
at scala.tools.nsc.StandardCompileClient.main0
(CompileClient.scala:94)
at scala.tools.ant.FastScalac.execute(FastScalac.scala:96)
at org.apache.tools.ant.UnknownElement.execute
(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown
Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute
(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute
(Sequential.java:62)
at org.apache.tools.ant.UnknownElement.execute
(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown
Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute
(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.MacroInstance.execute
(MacroInstance.java:394)
at org.apache.tools.ant.UnknownElement.execute
(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown
Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute
(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets
(Project.java:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:
1306)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets
(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:
1189)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run
(BridgeImpl.java:278)
at org.apache.tools.ant.module.run.TargetExecutor.run
(TargetExecutor.java:497)
at org.netbeans.core.execution.RunClassThread.run
(RunClassThread.java:151)
C:\Mark\misc\EntrepreneurInfo\IntelligentAdvertisingSoftware\testo
\nbproject\build-impl.xml:405: The following error occurred while
executing this line:
C:\Mark\misc\EntrepreneurInfo\IntelligentAdvertisingSoftware\testo
\nbproject\build-impl.xml:229: Compile failed because of an internal
compiler error (Exit from within execution engine, normal); see the
error output for details.
BUILD FAILED (total time: 2 seconds)





On Jun 30, 10:09 am, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> Personally, I'd use Scala's XML parsing to parse the feed... skip the
> external library.
> You may also want to look at the ESME codehttp://incubator.apache.org/esme/There's an RSS reader and a Twitter
> Beginning Scalahttp://www.apress.com/book/view/1430219890

David Pollak

unread,
Jul 1, 2009, 5:24:24 PM7/1/09
to lif...@googlegroups.com
On Wed, Jul 1, 2009 at 2:16 PM, Mark Essel <mes...@gmail.com> wrote:

Thanks David. I'm going with some direct calls for simplicity (along
the path you suggested).
along the lines of:

val rssFeed = XML.load( (new URL
(feedUrl)).openConnection.getInputStream )

One more oddity, I'm getting problems compiling normal scala code but
I can build lift projects (with scala inside them).

No clue about this... sorry.
 



--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890

Mark Essel

unread,
Jul 1, 2009, 6:00:04 PM7/1/09
to Lift
Thanks think I'm making progress
following this:
http://wiki.netbeans.org/Scala
after the install of 6.7RC3, jdk, scala plugin, lift, maven (used it
to get a test lift project)
my lift project worked with scala code inside the project

but what I didn't do was set SCALA_HOME, my class path appended with
that SCALA_HOME\bin and finally
add that option -J-Dscala.home=SCALA_HOME to the netbeans.conf

hoping that does it.

Not for nothing but I wonder why all the hoops to get a compiler + IDE
has so many little steps. Eclipse I tried something similar with but
never even got the lift project or maven working.

I come from an old makefile /command line library background, and
recently .NET libraries, mains (various languages).
Netbeans is still new to me (used once before for gcc in cygwin).
> > incubator.apache.org/esme/There's<http://incubator.apache.org/esme/There%27s>an RSS reader and a Twitter

Naftoli Gugenhem

unread,
Jul 1, 2009, 6:28:51 PM7/1/09
to mes...@gmail.com, lif...@googlegroups.com
Which maven plugin did you try for eclipse? M2eclipse works for me...

-------------------------------------

Mark Essel

unread,
Jul 2, 2009, 8:23:16 AM7/2/09
to Lift
Yeah Naftoli it was m2eclipse. May have been my failure to set
SCALA_HOME and the path properly.
I'll review it next time I do an eclipse setup (hopefully not for a
while now that netbeans is cooking with scala/lift)

Seriously, thanks much for all the feedback and help gents.

Mark Essel

unread,
Jul 2, 2009, 8:25:04 AM7/2/09
to Lift
ps found a nice code framework to help with my initial setup here from
Ted Neward
http://www.ibm.com/developerworks/java/library/j-scala06029.html
Will use some of those classes/objects to get started (Ted's cool with
it as long as I show him how it ends up)

On Jul 1, 6:28 pm, Naftoli Gugenhem <naftoli...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages