“FB.Canvas.Prefetcher.addStaticResource” doesn't work(FACEBOOK JS API) - javascript

I called Facebook js methods "FB.Canvas.Prefetcher.addStaticResource",
in IE 9 and chrome, if it works ,the resources could add to the staticresources,I
can check it in the Facebook Graph API Explorer. but it never happen.
My code:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '616151165162658',
status : true,
xfbml : true,
version : "v2.5",
cookie : true
});
FB.Canvas.Prefetcher.setCollectionMode(FB.Canvas.Prefetcher.COLLECT_MANUAL);
FB.Canvas.Prefetcher.addStaticResource('https://staging.ae-mobile.com:20443/mytest/1.2.3.0/resource/en/spine/cavemen_freespin.swf');
};</script>
I can got the breakpoint of this code, so I can sure the code runed.
The staticresources Explorer
image
is there any wrong.. why its not showing... have i call that methods in correct place..?
thanks in advance!

FB.Canvas.setDoneLoading(); after addstaticroute. and collection mode to COLLECT_AUTOMATIC. Also SSL certificate of your website is not valid.

Related

How to get posts from facebook page using javascript or php

I want post from my facebook page, can anyone please tell me the steps to do it? I see the solutions in web but can't getting what to do, can anyone help me to do this? I just have this code.
<html>
<script src="https://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<body>
<p>Log In with the JavaScript SDK</p>
<script>
logInWithFacebook = function() {
FB.login(function(response) {
if (response.authResponse) {
alert('You are logged in & cookie set!');
// Now you can redirect the user or do an AJAX request to
// a PHP script that grabs the signed request from the cookie.
} else {
alert('User cancelled login or did not fully authorize.');
}
});
return false;
};
window.fbAsyncInit = function() {
FB.init({
appId: 'my-app-key',
cookie: true, // This is important, it's not enabled by default
version: 'v2.2'
});
};
</script>
</body>
</html>
In your application you have inserted wrong domain details. Check your settings.
Select the correct App and click in the edit button;
Check the URLs & paths are correctly entered and are pointing to the site where you have installed Ultimate Facebook plugin.

How do I use Javascript to auto resize the height of my Facebook tab?

I am trying to create a simple HTML Facebook tab for my page, but I can't seem to find a fix for how to change the max height of the tab.
I should mention that I'm a beginner in coding, I know very basic HTML, but I've tried to avoid JavaScript since I have no experience with that whatsoever.
Unfortunately it seems like I can't do this without JavaScript, so my problem is most likely me doing something wrong.
The code looks something like this (the rest of the codes, including closing HTML-tags comes after the JavaScript part, and is working fine).
<!DOCTYPE html>
<html>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '***********', // App ID
channelUrl : '//**********', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional initialization code here
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript" charset="utf-8">
FB.Canvas.setAutoGrow();
</script>
I've pretty much copied the Javascript SDK from Facebook's developer pages and then found a small piece of code that should automatically set the height. I've googled for answers, but haven't been able to find anything that could fix this (or explain it in a way that an absolute newbie like me would understand).
Hope you can help me out.
//Frederik
Since You mentioned you know very basic html I assume you are not aware of the CSS possibilities as well, so I suggest you to replace this:
<div id="fb-root"></div>
with this:
<div id="fb-root" style="max-width: 100px;"></div>
Move this code FB.Canvas.setAutoGrow(); inside fbAsyncInit function, Example:
window.fbAsyncInit = function() {
FB.init({
appId : '***********', // App ID
channelUrl : '//**********', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Canvas.setAutoGrow();
};
If you want to set the size manually, you could do by using FB.Canvas.setSize() function:
FB.Canvas.setSize({height: 800});
Change the above number 800 to whatever size you want it to increase.

FB.Event.subscribe code not working

I am using this code to get the response:
<fb:like layout="button_count" notify="true" colorscheme="dark" href="http://www.fbrell.com"></fb:like>
<script>
// this will fire when any of the like widgets are "liked" by the user
FB.Event.subscribe('edge.create', function(href, widget) {
alert('You liked ' + href, widget);
});
</script>
It's not giving any response. Can anyone tell what wrong am i doing ?
Assuming that you have the FB Like button appearing, so you must be including the SDK correctly, I was in exactly the same situation - all you're missing is setting the subscribe up in the fbAsyncInit() function.
window.fbAsyncInit = function () {
FB.Event.subscribe('edge.create', function (targetUrl) {
_gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);
});
};
If you're doing this you don't need an application ID nor do you you need to use the FBML code, you can use the HTML5 inclusion code like <div class='fb-like' data-href='...
You're missing the inclusion of the javascript SDK files.
You're missing the FB.init
You're not running your code within the fbAsyncInit() function.
See https://developers.facebook.com/docs/reference/javascript/ for more information.
Checklist:
(Im assuming you have setup the Javascript SDK)
run the FB linter on your url, errors here may stop it working
http://developers.facebook.com/tools/debug
Include this at the top of the page
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
If your liking an app, include on your app page
<meta property="fb:app_id" content="Your app id" />
Like button, change href to your link
<fb:like layout="button_count" show_faces="false" height="21" href="http://facebook.com"></fb:like>
If its an app, FB prefers HTTPS
function init() {
FB.init({
appId: APP_ID,
status: true,
cookie: true,
xfbml: true,
oauth: true
});
//uncomment if required
//window.fbAsyncInit = function() {
FB.Event.subscribe('edge.create',
function(response) {
alert('You liked the URL: ' + response);
}
);
//}
}
init();

FB.Canvas.setUrlHandler

Are someone succed to use the method FB.Canvas.setUrlHandler please?
I've already read the following URL's
http://developers.facebook.com/docs/reference/javascript/FB.Canvas.setUrlHandler
http://​developers.facebook.com/blog/​post/555
but it still don't work... Someone to help me please?
Thanks in advance.
Here is my source code , when I execute this, nothing gets logged in the console:
<html>
<head>
</head>
<body >
<div id='fb-root'> </div>
<script type="text/javascript" src="http://?connect.facebook.net/en_US/?all.js"> </script>
<script type="text/javascript">
FB.init({
appId : 'MY_APP_ID',
oauth : true,
status : true,
cookie : true,
oauth : true,
xfbml: true
});
function testUrlHandler(data) {
if (data.path.indexOf("test1"?) != -1)
console.log('test1');
else if (data.path.indexOf("test2"?) != -1)
console.log('test2');
else
console.log('default');
}
FB.Canvas.setUrlHandler(te?stUrlHandler);
</script>
</body>
</html>
Per the documentation, the callback is only for links on the parent iframe (Facebook UI)
Registers the callback for inline processing (i.e. without page
reload) of user actions when they click on any link to the current app
from Canvas, including:
All ticker stories
Bookmarks
Requests from the bookmarks drop-down list
Request Notifications stories.
Your links in app wont fire the event.
I've spend 3 hours trying to understand what's wrong with it. Sometimes (really rare occasions ) this thing works just fine, and sometimes FB api just ignores this callback.
Solution - set the callback with delay after init, solution: How to work with facebook setUrlHandler?

How to get User info using JS SDK after they login with Facebook

I have this in my header:
<script src="http://connect.facebook.net/en_US/all.js"></script>
Then I have the FB login button code like this:
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=myAppId&xfbml=1">
</script><fb:login-button show-faces="false" perms="user_hometown,user_about_me,email,user_address"
autologoutlink="true" width="200" max-rows="1">
</fb:login-button>
Then after the user logs in with the FB button, how do I make a JS call to get their name, email, photo, etc?
I also found some code like this, but not sure where this is used:
<script>
FB.init({
appId : 'myAppId',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
channelURL : 'http://www.comehike.com/channel.html', // channel.html file
oauth : true // enable OAuth 2.0
});
</script>
Do I need the code right above?
Thanks!!
<html>
<head> ... </head>
<body>
<div id="fb-root"></div>
<fb:login-button show-faces="false" perms="user_hometown,user_about_me,email,user_address" autologoutlink="true" width="200" max-rows="1"></fb:login-button>
<!-- put this before the end body tag -->
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : 'myAppId',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
channelURL : 'http://www.comehike.com/channel.html', // channel.html file
oauth : true // enable OAuth 2.0
});
</script>
</body>
</html>
To get logged users data:
FB.api('/me', function(response) {
console.log(response);
});
If all went well response should be a JSON object containing the user data you have permission to view.
The users image can be gotten from:
http://graph.facebook.com/FACEBOOK_USER_ID/picture
You can specify the size you want with the type argument
square - 50x50
small - 50 pixels wide, variable height
normal - 100 pixels wide, variable height
large - about 200 pixels wide, variable height
For example:
http://graph.facebook.com/FACEBOOK_USER_ID/picture?type=large

Categories

Resources