Re: wicket facebook application

2012-04-10 Thread mnadeem

Look into this one

https://reachmnadeem.wordpress.com/2012/04/09/wicket-facebook/

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/wicket-facebook-application-tp3490139p4546617.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Serializing restfb DefaultFacebookclient in a wicket facebook application

2011-05-16 Thread labano10
@Sebastian, I actually used the part you
could also consider creating a new fbclient whenever you need one.  I am
using Guice but could not use request-scoped provider because the authToken
string which is needed in constructing fbClient is gotten from
pageparameters(for my case AppPage Parameters), so passing it to a provider
was tricky. 

I am happy it works, I just used methods within AppPage class which
construct and return restfb objects which means they r not part of page
state hence no serialization needed.

Thanks soo much.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Serializing-restfb-DefaultFacebookclient-in-a-wicket-facebook-application-tp3524700p3525647.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Serializing restfb DefaultFacebookclient in a wicket facebook application

2011-05-15 Thread labano10
I am building a facebook application in wicket using restfb api. 

After getting the authToken,I do the following in a wicket page:

FacebookClient fbclient = new DefaultFacebookClient(authToken); 

However, I keep receiving the error:

Error serializing object class com.mycompany.myApp.page.AppPage 

I know all model objects need to implement serializable, but
DefaultFacebookClient is from restfb. How should I handle this?



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Serializing-restfb-DefaultFacebookclient-in-a-wicket-facebook-application-tp3524700p3524700.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Serializing restfb DefaultFacebookclient in a wicket facebook application

2011-05-15 Thread labano10
I am building a facebook application in wicket using restfb api. 

After getting the authToken,I do the following in a wicket page:

FacebookClient fbclient = new DefaultFacebookClient(authToken); 

However, I keep receiving the error:

Error serializing object class com.mycompany.myApp.page.AppPage 

I know all model objects need to implement serializable, but
DefaultFacebookClient is from restfb. How should I handle this?



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Serializing-restfb-DefaultFacebookclient-in-a-wicket-facebook-application-tp3524707p3524707.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Serializing restfb DefaultFacebookclient in a wicket facebook application

2011-05-15 Thread Bas Gooren
I assume you create the fbclient within the AppPage class? If so, you'll 
need to store a serializable value/object in the page (or session) with 
which you can re-create the FacebookClient.
Your authToken variable would be a good starting point, see if that is 
serializable. If so, store the authToken and re-create the 
FacebookClient for every request where you need it.


Bas

Op 15-5-2011 20:58, schreef labano10:

I am building a facebook application in wicket using restfb api.

After getting the authToken,I do the following in a wicket page:

FacebookClient fbclient = new DefaultFacebookClient(authToken);

However, I keep receiving the error:

Error serializing object class com.mycompany.myApp.page.AppPage

I know all model objects need to implement serializable, but
DefaultFacebookClient is from restfb. How should I handle this?



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Serializing-restfb-DefaultFacebookclient-in-a-wicket-facebook-application-tp3524707p3524707.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Serializing restfb DefaultFacebookclient in a wicket facebook application

2011-05-15 Thread labano10
@Sebastian, authToken is basically a string. So you are saying I store it in
the wicket session, construct fbclient within session and call like
session.getfbclient when I want to use it. Or didn't I get you right? 

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Serializing-restfb-DefaultFacebookclient-in-a-wicket-facebook-application-tp3524700p3524749.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Serializing restfb DefaultFacebookclient in a wicket facebook application

2011-05-15 Thread Bas Gooren
No, since a session will also be serialized at some point, you will have 
the same problem, only less frequent.


What you can do is manage the client per request, either through a 
custom RequestCycle, or if you use google guice or something similar you 
can use a request-scoped provider.


Either way: simply create the fbclient only once per request.
I'm assuming that fbclient has some state which is needed in an 
interaction with facebook? If not, and construction is lightweight, you 
could also consider creating a new fbclient whenever you need one.


Bas

Op 15-5-2011 21:25, schreef labano10:

@Sebastian, authToken is basically a string. So you are saying I store it in
the wicket session, construct fbclient within session and call like
session.getfbclient when I want to use it. Or didn't I get you right?

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Serializing-restfb-DefaultFacebookclient-in-a-wicket-facebook-application-tp3524700p3524749.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



wicket facebook application

2011-05-02 Thread Josh Kamau
I am doing a facebook application in wicket. To get facebook authentication
token, I have written a wicket filter as below:



package com.mycompany.myapp.config;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.visural.common.StringUtil;

public class FBOAuth implements Filter {
public void init(FilterConfig fc) throws ServletException {
}

public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain
fc)
throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) sr;
HttpServletResponse res = (HttpServletResponse) sr1;
res.sendRedirect(FaceBook.getLoginRedirectURL());
String code = sr.getParameter(code);
if (StringUtil.isNotBlankStr(code)) {
String authURL = FaceBook.getAuthURL(code);
URL url = new URL(authURL);
try {
String result = readURL(url);
String accessToken = null;
Integer expires = null;
String[] pairs = result.split();
for (String pair : pairs) {
String[] kv = pair.split(=);
if (kv.length != 2) {
throw new RuntimeException(Unexpected auth
response);
} else {
if (kv[0].equals(access_token)) {
accessToken = kv[1];
}
if (kv[0].equals(expires)) {
expires = Integer.valueOf(kv[1]);
}
}
}
if (accessToken != null  expires != null)
{
HttpSession ses = req.getSession();
ses.setAttribute(authToken, accessToken);


} else {
throw new RuntimeException(
Access token and expires not found);
}
} catch (IOException e) {
throw new RuntimeException(e);
}

}
}
private String readURL(URL url) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream is = url.openStream();
int r;
while ((r = is.read()) != -1) {
baos.write(r);
}
return new String(baos.toByteArray());
}

public void destroy() {
}
}





In the doFilter method, I have done all the redirects required and gotten
the authentication token(accesstoken). At this point, I store the value as
an attribute to the httpSession which i have gotten by
ServleteRequest.getSession();

I want to acess this token in a wicket page class so that I use RestFB to
create a FaceBook Client etc. This is what I have done in the wicket page
class:

HttpSession session = null;

if (RequestCycle.get()!= null)
session = ((WebRequest) RequestCycle.get().getRequest())
.getHttpServletRequest().getSession();

if (session != null) {

System.out.print(# AuthToken: 
+ session.getAttribute(authToken));

}


However, this is the output I get and I am totally stuck:

# AuthToken: null


Where am i going wrong?


Re: wicket facebook application

2011-05-02 Thread Peter Karich
 Why not doing this directly the wicket-way with PageParameters and your
own Session?

FBPage(PageParameters params) {
   // do something with: params.getString(xy);

   // construct a new MySession object within the WicketApp.init method:
   // @Override Session newSession(Request request, Response response) {
   //   return new MySession(request); }

   // No need for complicated stuff just call 'getSession()' and get or
set the token:
   MySession session = (MySession)getSession();
   // session.getToken();
}

I've done similar things in jetwick for twitter authentication.

Regards,
Peter.



-- 
http://jetwick.com open twitter search


 I am doing a facebook application in wicket. To get facebook authentication
 token, I have written a wicket filter as below:



 package com.mycompany.myapp.config;

 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;

 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;

 import com.visural.common.StringUtil;

 public class FBOAuth implements Filter {
 public void init(FilterConfig fc) throws ServletException {
 }

 public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain
 fc)
 throws IOException, ServletException {
 HttpServletRequest req = (HttpServletRequest) sr;
 HttpServletResponse res = (HttpServletResponse) sr1;
 res.sendRedirect(FaceBook.getLoginRedirectURL());
 String code = sr.getParameter(code);
 if (StringUtil.isNotBlankStr(code)) {
 String authURL = FaceBook.getAuthURL(code);
 URL url = new URL(authURL);
 try {
 String result = readURL(url);
 String accessToken = null;
 Integer expires = null;
 String[] pairs = result.split();
 for (String pair : pairs) {
 String[] kv = pair.split(=);
 if (kv.length != 2) {
 throw new RuntimeException(Unexpected auth
 response);
 } else {
 if (kv[0].equals(access_token)) {
 accessToken = kv[1];
 }
 if (kv[0].equals(expires)) {
 expires = Integer.valueOf(kv[1]);
 }
 }
 }
 if (accessToken != null  expires != null)
 {
 HttpSession ses = req.getSession();
 ses.setAttribute(authToken, accessToken);


 } else {
 throw new RuntimeException(
 Access token and expires not found);
 }
 } catch (IOException e) {
 throw new RuntimeException(e);
 }

 }
 }
 private String readURL(URL url) throws IOException {
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 InputStream is = url.openStream();
 int r;
 while ((r = is.read()) != -1) {
 baos.write(r);
 }
 return new String(baos.toByteArray());
 }

 public void destroy() {
 }
 }





 In the doFilter method, I have done all the redirects required and gotten
 the authentication token(accesstoken). At this point, I store the value as
 an attribute to the httpSession which i have gotten by
 ServleteRequest.getSession();

 I want to acess this token in a wicket page class so that I use RestFB to
 create a FaceBook Client etc. This is what I have done in the wicket page
 class:

 HttpSession session = null;

 if (RequestCycle.get()!= null)
 session = ((WebRequest) RequestCycle.get().getRequest())
 .getHttpServletRequest().getSession();

 if (session != null) {

 System.out.print(# AuthToken: 
 + session.getAttribute(authToken));

 }


 However, this is the output I get and I am totally stuck:

 # AuthToken: null


 Where am i going wrong?



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org