How to Get Sessionkey by using Facebook javascript API - facebook

I am Using the following code to use Fconnect in my website:
<script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" ></script>
<div id="fb-root"></div>
<script type="text/javascript" language="javascript">
FB_RequireFeatures(["XFBML"], function () {
FB.init(MY_App_ID, Domain_Path + "xd_receiver.htm");
});
</script>
<fb:login-button length='short' size='medium' onlogin="facebook_onlogin_ready()" ></fb:login-button>
previously the following code was returning the Session Key but now its not.
FB.Facebook.apiClient.get_session()
its giving Undefined error
How i can get User SessionKey using the Facebook Jascript Api.

That code is using a deprecated API which is no longer supported and could be removed at any time as it's scheduled for deletion.
The current Javascript SDK uses OAuth access tokens, not session keys.

Related

Bing maps: Specified credentials invalid

I can't seem to get Bing to accept my API key from my dev server-- I've set up an API key from the bingmapsportal.com site, and set the URL to http://localhost and generated the key successfully.
I then implement the map as shown in the API docs, as follows:
<html>
<head>
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
<script type="text/javascript">
function getMap(){
var mapInitOpts = {
credentials: 'mycredentials',
mapTypeId: Microsoft.Maps.MapTypeId.road
};
var map = new Microsoft.Maps.Map(document.getElementById("map_canvas"), mapInitOpts);
}
</script>
</head>
<body onload="getMap();">
<div id='map_canvas' style="position:absolute; top:0px; left:0px; width:100%; height:100%;"></div><br />
</body>
</html>
// map shows invalid credentials error
However, I always get the "Specified credentials invalid" message.
Any ideas on this issue?
Assuming you had 'mycredentials' act as a place holder for your actual credentials for this question posting, try using the API key from the interactive SDK:
AjtUzWJBHlI3Ma_Ke6Qv2fGRXEs0ua5hUQi54ECwfXTiWsitll4AkETZDihjcfeI
If the above works, and the key you obtained doesn't, then something is wrong with your key and you need to work with Bing Dev Support.
If the above key doesn't work, then there is something wrong with your development environment...

Fconnect Button is not Generating

I am using the following code to generate Fconnect button in my web application to integrate Fb login.
Previously this code was working fine. but now its not showing me the fconnect button in my webpage.
what is wrong with this code. Or is there any changes to the facebook Api?
<script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" ></script>
<div id="fb-root"></div>
<script type="text/javascript" language="javascript">
FB_RequireFeatures(["XFBML"], function () {
FB.init(MY_App_ID, Domain_Path + "xd_receiver.htm");
});
</script>
<fb:login-button length='short' size='medium' onlogin="facebook_onlogin_ready()" ></fb:login-button>

registration-url parameter fails for fb:login-button if oauth 2.0 is enabled

I'm trying to get the registration flow for Facebook login working. Here's a bare-bones example:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>My Facebook Login Page</title>
</head>
<body>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<div id="fb-root"></div>
<script type="text/javascript">
FB.init({
appId:'xxxxxxxxxxx',
cookie:true,
status:true,
xfbml:true,
channelUrl : 'http://<myWebSite>/channel.html',
oauth:true
});
</script>
<fb:login-button registration-url="http://<myWebSite>/register"/>
</body>
</html>
(The only things I've replaced above are the website and the appID)
If I try it like this, the login button shows up, but clicking it causes FireBug to report 'Unknown status: undefined' in the browser log. If I remove the 'oauth=true' line though, it works. I'm trying to adhere to the new oauth 2.0 standard, so I'd like to leave it in. Has anyone else run into this? Seems like if this was a bug, it would have been caught pretty early on.
the 'registration-url' parameter is no longer supported by , take a look in the documentation of it. http://developers.facebook.com/docs/reference/plugins/login/
Just check if the user is logged in via the JS-SDK

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 :)

Facebook-IFrame

I am developing a facebook application using IFrame. how to add share option in my application.
You need to use XFBML in an Iframe application.
This should work. Put your Facebook application's API Key in and reference your cross-domain receiver file (xd_receiver)
<fb:share-button href="http://apps.facebook.com/your_app" type="box_count"></fb:share-button>
<script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">
FB_RequireFeatures(["XFBML"], function() {
FB.init("api key goes here", "path to your xd_receiver file goes here");
});
</script>