F-connect

37 views
Skip to first unread message
Message has been deleted
Message has been deleted

taltun

unread,
Apr 14, 2010, 8:48:28 AM4/14/10
to RestFB
Hi,

I have a java web application (jsp, struts 2). I try to integrate
Facebook connect in my webapplication. I've created a facebook
application (apikey) http://wiki.developers.facebook.com/index.php/Connect/Setting_Up_Your
...

I need a f-connect popup using RestFB. I
do not know where I should start by creating a facebook connect
integration with facebook by use of RestFB.

Is there some code examples that relate specifically about f-connect
by use of RestFB or is it possible for a person to provide a
example of how it can be done.

I think that there will be several that will have
benefit from this example.

-taltun

revetkn

unread,
Apr 14, 2010, 11:44:04 AM4/14/10
to RestFB
Hi Taltun -

Thank you for translating from the original Danish, this is much
easier for me to read :)

The first step after creating an application is to set up a connect
URL that points to your server. On that server, you can perform
Facebook Connect authentication using Javascript and dump out the
session key. Here's an abbreviated example which uses jQuery to
display the authentication popup and dump out all the authentication
information afterwards:

...
<script src="https://www.connect.facebook.com/js/api_lib/v0.4/
FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$("#facebookConnectButton").click(function() {
FB_RequireFeatures(["Connect"], function() {
FB.init("123456789" /* Your app's API key */, "/your/path/to/
xd_receiver", {
permsToRequestOnConnect: "read_stream,offline_access",
});
FB.ensureInit(function() {
FB.Connect.requireSession(function() {
FB.Connect.ifUserConnected(function(uid) {
var session = FB.Facebook.apiClient.get_session();
$("#facebookSessionDataList").empty();

for(key in session)
$("#facebookSessionDataList").append("<li><b>" + key + "</b>: "
+ session[key] + "</li>");
});
});
});
});
});
});
</script>

</head>
<body>
<input id="facebookConnectButton" type="button" value="Connect to
Facebook"/>
<br/><br/>
<ul id="facebookSessionDataList"></ul>
...

Make sure you follow the instructions carefully on the Facebook
Connect website and don't forget to properly set up your xd_receiver
page.

Once you successfully get a session key from that, you can use it in
your RestFB calls.

Since I've been getting a lot of questions around this, I will try to
do a better job of documenting the process and providing examples.
I've been steering clear of that so far since this is more of a
Facebook Connect integration issue, not a RestFB issue, but RestFB
does depend on a correct Facebook Connect setup.

Thanks
Mark

On Apr 14, 8:48 am, taltun <tunca...@gmail.com> wrote:
> Hi,
>
> I have a java web application (jsp, struts 2). I try to integrate
> Facebook connect in my webapplication. I've created a facebook

> application (apikey)http://wiki.developers.facebook.com/index.php/Connect/Setting_Up_Your

taltun

unread,
Apr 14, 2010, 5:06:43 PM4/14/10
to RestFB
Hi Mark,

Thank you very much with a nice jQuery example!!

Now I get the session key :))

But I'm little bit stuck having following questions:

1. What is the session key - is it the unique id identifying a
facebook user, does it expire ?
2. Should I map the session key with the created user account on my
website ?
3. Using offline_access you said that the session key will be stored
on client and reused by the client to call the facebook api without
need for reauthentifcation, correct ? When does the session key
expire ?

Next, I will go using the RestFB client API :))

Thanks!!

-tuncay

revetkn

unread,
Apr 14, 2010, 5:14:20 PM4/14/10
to RestFB
Hi there -

Take a look at the Facebook docs which outline how sessions and
extended permissions (such as offline_access) work:

http://wiki.developers.facebook.com/index.php/Getting_Started:_Understanding_Sessions
http://wiki.developers.facebook.com/index.php/Extended_permissions

A session key will uniquely identify a Facebook user, as it includes
the user's UID. You could, with the offline_access permission
granted, store the session key in your database, mapping it to a user
record. For example, if you already have a user table, you might add
a "facebook_session_key" column and store it off there.

I believe that the offline_access permission is essentially permanent
unless the user manually deauthenticates, but I'm not entirely sure.

Thanks
Mark

taltun

unread,
Apr 15, 2010, 4:15:59 AM4/15/10
to RestFB
Ok, I will read the doc. I look forward to working with RestFB.

I appreciate your big help, thanks!

-tuncay


On Apr 14, 11:14 pm, revetkn <mark.a.al...@gmail.com> wrote:
> Hi there -
>
> Take a look at the Facebook docs which outline how sessions and
> extended permissions (such as offline_access) work:
>

> http://wiki.developers.facebook.com/index.php/Getting_Started:_Unders...http://wiki.developers.facebook.com/index.php/Extended_permissions

Reply all
Reply to author
Forward
0 new messages