Resume FB Connect session - facebook

i am using FB Connect on my site and i am able get & store offline access session key in DB.
My question, i need to display the multiple friend selector form even if there is no FB connect session.
How can i force it to resume/create the session i have in DB, so i can display friends in the below form.
Since i already got extended permissions, I must not ask them for login again. please help
require_once 'config.php';
$user = "1294712371";
$session = "827466297c301f2cc6b581ce-1294712371";
?>
<fb:serverfbml style="align:center;">
<script type="text/fbml">
<fb:fbml>
<fb:request-form
action="test.php"
method="POST"
invite="true"
type="dot.com"
content="Come and join me"
<fb:req-choice url='see wiki page for fb:req-choice for details'
label='Join Me' />
<fb:multi-friend-selector showborder="false"
actiontext="Invite your friends">
</fb:request-form>
</fb:fbml>
</script>
</fb:serverfbml>
<script src="JS/FeatureLoader.js" type="text/javascript"></script>
<script type="text/javascript">
FB_RequireFeatures(["XFBML"], function()
{
FB.init('appapikey', "xd_receiver.htm");
});
</script>
Currently the above code shows no friends at all when there is no FB connect loggedin sesstion

You could use set_user method from the php client library
$facebook = new Facebook(API_KEY, API_SECRET);
$facebook->set_user($user, $session);

Related

Facebook request form not working in HTML

I am using facebook request form for my facebook iframe fanpage,
I am using below code for this
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
FB.Canvas.setAutoResize();
</script>
</head>
<body>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js"></script><script>
FB.init({
appId:"APP_ID", cookie:true,
status:true, xfbml:true
});
</script>
<fb:serverFbml width="760px">
<script type="text/fbml">
<fb:fbml>
<fb:serverFbml style="width: 755px;">
<script type="text/fbml">
<fb:fbml>
<fb:request-form
action="<URL for post invite action, see fb:request-form docs for details>"
method="POST"
invite="true"
type="XFBML"
content="This is a test invitation from XFBML test app
<fb:req-choice url="see fb:req-choice docs for details."
label="Ignore the Facebook test app!" />
">
<fb:multi-friend-selector
showborder="false"
actiontext="Invite your friends to use Facebook." />
</fb:request-form>
</fb:fbml>
</script>
</fb:serverFbml>
</fb:fbml>
</script>
</fb:serverFbml>
The code was working ok earlier around 15-20 days back, now the same is not working. Now only loading frame appears instead of list of friends.
Please suggest how to overcome this issue?
Thanks in advance for the help
this works (for the time being): http://www.ajado.com/blog/embedding-a-xfbml-facebook-friend-invite-request-form-javascript-only/
however, i did not find a way to get this part working:
<fb:req-choice url="see fb:req-choice docs for details."
label="Ignore the Facebook test app!" />
">

need to invite facebook friends to mysite

I will implement a functionality that let users to invite their facebook friends (explicity choosing or let exclude some of them) to our site (I dont know what is possible with facebook api but possible cases: 1- sending plain email to friends 2- facebook message, invitation in facebook platform). I am facebook platform newbie and dont know where to start. Could you recommend which API should I use (facebook connect , facebook graph etc)? I read that facebook api and permission is changing rapidly. What is the state of the art way of doing this task?
You have to create one facebook app first.
Heres the link for creating facebook app.
https://www.facebook.com/developers/createapp.php
Then after put the following code in your application.
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
//Your app details here
FB.init({appId: 'your-app-id', status: true, cookie: true, xfbml: true});
};
//Load the SDK asynchronously
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
<fb:serverfbml>
<script type="text/fbml">
<fb:fbml>
<fb:request-form
action="url-after-inviting"
method="POST"
invite="true"
type="Name of site"
content="Text you want to keep along.
<fb:req-choice url='link-to-your-website'
label='<?php echo htmlspecialchars("Invite Now!",ENT_QUOTES); ?>'/>"
>
<fb:multi-friend-selector
showborder="false"
actiontext="title-text"
exclude_ids="<?php //echo $excludeIds; ?>"
rows="3"
/>
</fb:request-form>
</fb:fbml>
</script>
</fb:serverfbml>

problem in fb:request-form

In the my facebook app i m using fb request form there i want to know that user has send friend request to any one or just skip the page.
code is
<fb:serverFbml width= "620" style="float:center">
<script type="text/fbml">
<fb:fbml>
<fb:request-form
action='<?php echo $config["base_url"]."?action=3;?>'
target="_top"
method="POST"
invite="true"
type="....some thing"
content="...some thing"
>
<fb:multi-friend-selector target="_top"
showborder="false"
actiontext="----" rows='4' cols='4' max='1' import_external_friends = "false">
</fb:request-form>
</fb:fbml>
</script>
</fb:serverFbml>
as the developer document says that if user either send the request or skip the request page it will go to action URL . Is there any thing to differentiate between these two case.
Please ignore any English grammar mistake.
Thanks in Advance.
The information you're looking for is most likely included in the server response, check it.
Btw, FBML is going to be deprecated very soon, so if this is a new application, you better switch to the JavaScript SDK.

Redirection is not happening correctly after sharing an app usign the multi-friend-selector

I'm using the facebook multi-friend-selector in my facebook page which is loading all my friends in an iFrame. But after selecting a friend from the list and sending an invitation then redirection is not happening correctly to the corresponding callback URL.
I just struck up with this issue, can anybody please help me to fix this issue.
My code for the multi-friend-selector is:
<fb:serverfbml>
<script type="text/fbml">
<fb:fbml>
<fb:request-form action="http://gelofactory.com/dev/SPIN/SXSW/share.php" method="POST" invite="true" type="Download" content="Sharing">
<fb:multi-friend-selector showborder="false" bypass="cancel" email_invite="false" import_external_friends="false" actiontext="Share with your friends." cols="3" rows="3" />
</fb:request-form>
</fb:fbml>
</script>
</fb:serverfbml>
Thanks,
Siva
Are you getting any errors? anyway, here are some suggestions:
Please consider using the new Requests Dialog
Make sure you are using the Canvas URL in the action parameter: http://CANVAS_URL/path/to/share.php

Can I use Facebook's fb:friend-selector in an iframe?

I'm trying to use Facebook's fb:friend-selector FBML tag, but my application is running in an iframe. Is it possible to use this tag in an iframe? If so does anyone have any examples?
Yes, this is definitely possible, but you have to use Facebook Connect and XFBML. Specifically, you want to use the fb:serverfbml tag to get fb:friend-selector working. I have an iframe app whereby I use all of this and the fb:friend-selector in the standard "invite friends to your app" context, and it works great.
Here is the body of my template file, which gets output inside the body of my iframe:
<fb:serverfbml style="width: 650px;">
<script type="text/fbml">
<fb:fbml>
<fb:request-form
action="http://example.com/invite/sent"
method="POST"
invite="true"
type="My App"
content="Try out my app!
<fb:req-choice url='http://your-facebook-canvas-url'
label='<?php echo htmlspecialchars("Accept button text",ENT_QUOTES); ?>'
/>
" >
<fb:multi-friend-selector
showborder="false"
actiontext="Invite your friends to try My App."
exclude_ids="<?php echo $excludeIds; ?>"
rows="3"
/>
</fb:request-form>
</fb:fbml>
</script>
</fb:serverfbml>
In the footer of the page, I have the standard Facebook Connect code, which will load and render the fb:serverfbml contents:
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">
FB_RequireFeatures(
["CanvasUtil"],
function(){
FB.XdComm.Server.init('/xd_receiver.html');
FB.CanvasClient.startTimerToSizeToContent();
}
);
</script>
<script type="text/javascript">
FB_RequireFeatures(["XFBML"], function(){ FB.Facebook.init("Your Facebook API Key", "/xd_receiver.html"); });
</script>
That should be all you need (fill in your own options where applicable, of course). You'll have to set up Facebook Connect to work with a cross-domain receiver file. I suggest following the rendering XFBML steps.
The question in this thread is still relevant but the answer is out of date. You should use the new javascript SDK. This should replace the second code snippet posted by zombat
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
FB.init({appId: 'your app id',
status: true,
cookie: true,
xfbml: true});
FB.Event.subscribe('auth.sessionChange', function(response) {
if (response.session) {
// A user has logged in, and a new cookie has been saved
} else {
// The user has logged out
}
});
</script>
more info here: http://www.clickonchris.com/2010/11/facebook-javascript-sdks/
Since that are a lot of questions about the friend-selector within an iframe.
Guys the correct sintax now is <fb:serverfbml width="650px">
one MAJOR and IMPORTANT point that gets missed is that many of you (including me) stick in scripts just about anywhere... but the "FB" load.js file needs to be loaded IMMEDIATELY after the body tag.
at least this is what I found to make everything work and humm accordingly. I found it on a post on some other site (wasn't sure if I should post it here or not...) but it came after spending countless hours, doing the above aforementioned - as well as following every other 1,2, 3 step punch into getting the iframe to size properly...
and now i've gotten it to work :)