[Lift] Re: Facebook Application

2010-02-09 Thread Leo Lännenmäki
Hi,

I'll definitely take a look. But I think FB connect is not applicable
for our use..

Here a simple version of the use:
- We have a Lift application providing a RESTfull JSON API for our
clients. Through that API a client application can share a photo to
Facebook
- We have a Web client for the API provided by the Lift server looming
on a different machine. That client does the FB login in order to get
a token for the user.
- That token is sent to the Lift server which uses it to create a new
client (val client = FacebookClient.fromAuthToken(authToken).get)
- When the user shares a photo through our API that fb client is used
to upload the photo to Facebook


On Feb 9, 6:06 am, Jonathan Hoffman jonhoff...@gmail.com wrote:
 Hi All,

 I just created issue #336 to provide a Facebook Connect helper and example 
 application.  You can take a look at what I've got 
 here:http://github.com/dpp/liftweb/commit/3b6686201e3b7f22100e52a04734fd4c...

 Leo, if you're trying to use fb connect, hopefully this will help you out (I 
 would suggest using connect rather than redirecting to FB)

 Will push out to master pending your comments and RB.

 - Jon

 On Feb 5, 2010, at 10:35 AM, Leo Lännenmäki wrote:

  Hi,

  I have only tried to do a couple of things with the Facebook module
  (I'm using 2.0-M1) and I have gotten some of the stuff to actually
  work :)

  Photo upload would be something like this:

  import java.io.File
  import org.apache.commons.io.FileUtils
  import net.liftweb.ext_api.facebook._
  import scala.xml._

  FacebookRestApi.apiKey = your api key
  FacebookRestApi.secret = secret

  // Get a user to login to Facebook with a link like
 http://www.facebook.com/login.php?v=1.0api_key=your api key
  // If you mess around with the Facebook settings you will get FB to
  // redirect the user back to your app with a token as a query param

  val authToken = as described previously
  val client = FacebookClient.fromAuthToken(authToken).get
  val photo = new File(...)
  val bytes = FileUtils.readFileToByteArray(photo)
  val resp = client !? UploadPhoto(test.jpg, jpg, bytes)
  val photoUrl = (resp \\ link).text

  Getting a list of friends:
  val resp = client !? GetFriends()

  Some real documentation and examples sure would be nice!

  Leo

  On Feb 3, 9:00 am, celestocalculus celestocalcu...@yahoo.co.uk
  wrote:
  Hello,
  I'm an intermediate lift developer. Suddenly, it has become my first
  choice framework for web applications. I really think it's a nice
  framework you guys are doing a great job.
  I'm new on facebook application development and I have been looking at
  the liftweb facebook API. I really don't know how to put this but I'm
  just blank, I don't know where to start. I would really appreciate it
  if I get a step by step explanation. All the book I got on facebook
  apps are on php and I find it difficult to match the php codes to
  their corresponding lift counterparts.

  Please I'll also appreciate sample codes, please let it be step by
  step and on point.

  Thanks in advance.

  --
  You received this message because you are subscribed to the Google Groups 
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to 
  liftweb+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/liftweb?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.



[Lift] Re: Facebook Application

2010-02-05 Thread Leo Lännenmäki
Hi,

I have only tried to do a couple of things with the Facebook module
(I'm using 2.0-M1) and I have gotten some of the stuff to actually
work :)

Photo upload would be something like this:

import java.io.File
import org.apache.commons.io.FileUtils
import net.liftweb.ext_api.facebook._
import scala.xml._

FacebookRestApi.apiKey = your api key
FacebookRestApi.secret = secret

// Get a user to login to Facebook with a link like
http://www.facebook.com/login.php?v=1.0api_key=your api key
// If you mess around with the Facebook settings you will get FB to
// redirect the user back to your app with a token as a query param

val authToken = as described previously
val client = FacebookClient.fromAuthToken(authToken).get
val photo = new File(...)
val bytes = FileUtils.readFileToByteArray(photo)
val resp = client !? UploadPhoto(test.jpg, jpg, bytes)
val photoUrl = (resp \\ link).text

Getting a list of friends:
val resp = client !? GetFriends()

Some real documentation and examples sure would be nice!

Leo

On Feb 3, 9:00 am, celestocalculus celestocalcu...@yahoo.co.uk
wrote:
 Hello,
 I'm an intermediate lift developer. Suddenly, it has become my first
 choice framework for web applications. I really think it's a nice
 framework you guys are doing a great job.
 I'm new on facebook application development and I have been looking at
 the liftweb facebook API. I really don't know how to put this but I'm
 just blank, I don't know where to start. I would really appreciate it
 if I get a step by step explanation. All the book I got on facebook
 apps are on php and I find it difficult to match the php codes to
 their corresponding lift counterparts.

 Please I'll also appreciate sample codes, please let it be step by
 step and on point.

 Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.



[Lift] Re: S.params disappear?

2010-02-05 Thread Leo Lännenmäki
Hmpf. Same problem here :(

def statefulDispatchTable: LiftRules.DispatchPF = {
  ...
  case r...@req(List(api, foo), , PutRequest) = () =
update(req)
  ...
}

def update(req: Req): LiftResponse = {
  for (name - req.paramNames) {
Log.info(name)
Log.info(req.param(name).openOr(empty))
  }
  ...
}


On Jetty:
209467 [736850...@qtp-566947760-0] INFO  lift  - param
209467 [736850...@qtp-566947760-0] INFO  lift  - value
209476 [736850...@qtp-566947760-0] INFO  lift  - Service request
(PUT) /api/foo took 17 Milliseconds

curl -v -X PUT -d param=value -b JSESSIONID=v7a6qye5zusv
http://localhost:8080/api/foo
* About to connect() to localhost port 8080 (#0)
*   Trying ::1... connected
* Connected to localhost (::1) port 8080 (#0)
 PUT /api/users/0505710286 HTTP/1.1
 User-Agent: curl/7.19.5 (x86_64-pc-linux-gnu) libcurl/7.19.5 OpenSSL/0.9.8g 
 zlib/1.2.3.3 libidn/1.15
 Host: localhost:8080
 Accept: */*
 Cookie: JSESSIONID=v7a6qye5zusv
 Content-Length: 49
 Content-Type: application/x-www-form-urlencoded

 HTTP/1.1 200 OK
 Content-Length: 0
 Content-Type: text/html; charset=utf-8
 X-Lift-Version: 2.0-M1
 Server: Jetty(6.1.22)

* Connection #0 to host localhost left intact
* Closing connection #0



On Tomcat:
170570 [http-8080-2] INFO  lift  - Service request (PUT) /tumps-server/
api/users/0505710286 took 12 Milliseconds

curl -v -X PUT -d param=value -b
JSESSIONID=68EE8A10FFBC2E5383FB9FD2821CF0E1 
http://localhost:8080/myserver/api/foo
* About to connect() to localhost port 8080 (#0)
*   Trying ::1... connected
* Connected to localhost (::1) port 8080 (#0)
 PUT /tumps-server/api/users/0505710286 HTTP/1.1
 User-Agent: curl/7.19.5 (x86_64-pc-linux-gnu) libcurl/7.19.5 OpenSSL/0.9.8g 
 zlib/1.2.3.3 libidn/1.15
 Host: localhost:8080
 Accept: */*
 Cookie: JSESSIONID=68EE8A10FFBC2E5383FB9FD2821CF0E1
 Content-Length: 49
 Content-Type: application/x-www-form-urlencoded

 HTTP/1.1 200 OK
 Server: Apache-Coyote/1.1
 X-Lift-Version: 2.0-M1
 Content-Type: text/html;charset=utf-8
 Content-Length: 0
 Date: Fri, 05 Feb 2010 16:28:23 GMT

* Connection #0 to host localhost left intact
* Closing connection #0

-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.



[Lift] Re: S.params disappear?

2010-02-05 Thread Leo Lännenmäki
Hmpf. I have got the Tomcat PUT problem also.

def statefulDispatchTable: LiftRules.DispatchPF = {
  ...
  case r...@req(List(api, foo), , PutRequest) = () =
update(req)
  ...
}

def update(req: Req): LiftResponse = {
  for (name - req.paramNames) {
Log.info(name)
Log.info(req.param(name).openOr(empty))
  }
  ...
}


On Jetty:
209467 [736850...@qtp-566947760-0] INFO  lift  - param
209467 [736850...@qtp-566947760-0] INFO  lift  - value
209476 [736850...@qtp-566947760-0] INFO  lift  - Service request
(PUT) /api/foo took 17 Milliseconds

curl -v -X PUT -d param=value -b JSESSIONID=v7a6qye5zusv
http://localhost:8080/api/foo
* About to connect() to localhost port 8080 (#0)
*   Trying ::1... connected
* Connected to localhost (::1) port 8080 (#0)
 PUT /api/foo HTTP/1.1
 User-Agent: curl/7.19.5 (x86_64-pc-linux-gnu) libcurl/7.19.5 OpenSSL/0.9.8g 
 zlib/1.2.3.3 libidn/1.15
 Host: localhost:8080
 Accept: */*
 Cookie: JSESSIONID=v7a6qye5zusv
 Content-Length: 49
 Content-Type: application/x-www-form-urlencoded

 HTTP/1.1 200 OK
 Content-Length: 0
 Content-Type: text/html; charset=utf-8
 X-Lift-Version: 2.0-M1
 Server: Jetty(6.1.22)

* Connection #0 to host localhost left intact
* Closing connection #0



On Tomcat:
170570 [http-8080-2] INFO  lift  - Service request (PUT) /api/foo took
12 Milliseconds

curl -v -X PUT -d param=value -b
JSESSIONID=68EE8A10FFBC2E5383FB9FD2821CF0E1 
http://localhost:8080/myserver/api/foo
* About to connect() to localhost port 8080 (#0)
*   Trying ::1... connected
* Connected to localhost (::1) port 8080 (#0)
 PUT /api/foo HTTP/1.1
 User-Agent: curl/7.19.5 (x86_64-pc-linux-gnu) libcurl/7.19.5 OpenSSL/0.9.8g 
 zlib/1.2.3.3 libidn/1.15
 Host: localhost:8080
 Accept: */*
 Cookie: JSESSIONID=68EE8A10FFBC2E5383FB9FD2821CF0E1
 Content-Length: 49
 Content-Type: application/x-www-form-urlencoded

 HTTP/1.1 200 OK
 Server: Apache-Coyote/1.1
 X-Lift-Version: 2.0-M1
 Content-Type: text/html;charset=utf-8
 Content-Length: 0
 Date: Fri, 05 Feb 2010 16:28:23 GMT

* Connection #0 to host localhost left intact
* Closing connection #0


On Feb 4, 10:47 pm, David Pollak feeder.of.the.be...@gmail.com
wrote:
 Sounds to me like a Tomcat issue... I think we're relying on the container
 to parse the body correctly.



 On Wed, Feb 3, 2010 at 9:15 PM, c...@munat.com wrote:
  It's POST vs. PUT. I'm using AJAX, so I can do PUTs.

  The two are identical, except:

  POST instead of PUT

  The POST version includes:

  Pragma: no-cache
  Cache-Control: no-cache

  which the PUT does not. In other words, the headers are identical except
  for the above.

  In Jetty, no problem. In Tomcat, the params are ignored. They do not show
  up in S.params. At all.

  I can't imagine that this is a Lift issue, unless Tomcat makes params
  available differently for PUTs than for POSTs, but Jetty does not, and I'm
  the first guy to do PUTs to Lift on Tomcat. But I've emailed the Tomcat
  users list and we'll see if it's something simple. If not, I'll put
  something on GitHub.

  Chas.

   Is it a POST or a GET?

   On Wed, Feb 3, 2010 at 11:44 PM, c...@munat.com wrote:

   Thanks, David.

   That's a non-trivial exercise for me, so let me chase down another lead
   at
   the moment. If that proves fruitless, I'll bite the bullet and get
   something up on GitHub.

   Chas.

Please put together a reproduceable example on GitHub (works in Jetty,
doesn't work in Tomcat) and we'll look at it.

On Wed, Feb 3, 2010 at 11:48 AM, c...@munat.com wrote:

I have a lift app that works perfectly when I use mvn jetty:run. Then
   I
package it into a war and load it up in Tomcat 6 on the server, and
   when
I
do, suddenly it won't work.

The issue is with the S.params. I have a form that submits via an
   Ajax
PUT
request. The params are sent in the header just fine. As I said,
   works
like a charm on Jetty. But when it gets to Tomcat, the entity is
   saved
with blank attributes... i.e., everything worked but the
S.param(whatever) showed up blank. I tested this by doing
S.param(whatever).openOr(Phooey) and, indeed, that attribute was
   set
to Phooey on the new entity.

Tomcat issue? Or am I missing something obvious? This form is running
   on
a
subdomain, so that's where I'm looking now (in server.xml).

TIA,
Chas.

--
You received this message because you are subscribed to the Google
Groups
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to
liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
  liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com

   liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com
  liftweb%252bunsubscr...@googlegroups.comliftweb%25252bunsubscr...@googlegroups.com

.
For more options, visit this group at
   http://groups.google.com/group/liftweb?hl=en.


[Lift] Re: Building war for production mode.

2009-11-28 Thread Leo Lännenmäki
Hi,

I'm a Lift newbie so I don't know if my way is the right way but
here goes:

I generated my app using the archetype lift-archetype-basic in order
to get the database configuration stuff to Boot.scala. Then i created
two files src/main/webapp/WEB-INF/classes/props/default.props and
production.default.props. When developing I want to use an in memory
database so I added:

db.driver = org.apache.derby.jdbc.EmbeddedDriver
db.url = jdbc:derby:my_database_name;create=true

to default.props. I want to use MySQL on the production server so I
added:

db.driver = com.mysql.jdbc.Driver
db.url = jdbc:mysql://localhost:3306/my_database_name
db.user = my_user
db.password = my_pass

to production.default.props. On the production server I user Tomcat
with -Drun.mode=production.

I hope you get some ideas about my configuration.

Leo

On Nov 28, 11:02 am, Neil.Lv anim...@gmail.com wrote:
   Now the lift app runs in the production mode,

 ###
   put the JAVA_OPTIONS=-Drun.mode=production on the top, and it can
 workd.
 ###

  But it will create the database in the jetty's folder
  /home/jetty6/derby.log
  /home/jetty6/lift_example

   It can's find the jdbc:mysql ?  (It the development mode it can find
 the jdbc:mysql driver)

   I don't know what's the problem with it .

   Thanks for any help!

 Cheers,
   Neil

 On Nov 28, 3:48 pm, Neil.Lv anim...@gmail.com wrote:

  I have the same issue, is add this statement into /home/jetty6/bin/
  jetty.sh

  ###
    echo JAVA_OPTIONS=-Drun.mode=production  /home/jetty6/bin/
  jetty.sh
  ###

   then restart the jetty server, but it alwasy show the Development
  Mode information
   The requested page was not defined in your SiteMap, so access was
  blocked

    The server is CentOS 5.3

  Cheers,
    Neil

  On Nov 27, 7:13 pm, Jeppe Nejsum Madsen je...@ingolfs.dk wrote:

   Marcin Jurczuk mjurc...@gmail.com writes:
Hello,

I'm trying to first test deploy of my app :)

I created package (mvn package), uploaded created war as root.war in
webapp folder of jetty server and when running app it looks that lift
app is running in development mode (no 404 is showed but:
The requested page was not defined in your SiteMap, so access was
blocked.  (This message is displayed in development mode only

How inform maven that I'm building production package ?
I tried mvn -Drun.mode=production package  - no effect ?

   You don't build for deployment, it is the same war (modulus any compiler
   settings or other build steps you've specified)

   The lift run mode is determined at runtime, so you need to specify the
   run.mode=production as a system property when launching jetty

   (This is what happens with the maven command above: It starts jetty with
   this system property set)

   If you happen to run jetty on a Debian based Linux you can accomplish
   this by:

   echo JAVA_OPTIONS=-Drun.mode=production /etc/default/jetty6

   /Jeppe

--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.