Facebook Canvas App cant login to Developer - javascript

when Try to login Facebook Canvas App only Developer can't login to App Show following Error
Invalid Scopes: read_friendlists. This message is only shown to
developers. Users of your app will ignore these permissions if
present. Please read the documentation for valid permissions at:
https://developers.facebook.com/docs/facebook-login/permissions
I use Following code inside index.php file and bottom of the code
window.fbAsyncInit = function() {
FB.init({
appId : '<?php echo APP_ID;?>',
xfbml : true,
version : 'v2.3'
});
function onLogin(response) {
if (response.status == 'connected') {
FB.api('/me?fields=first_name', function(data) {
var welcomeBlock = document.getElementById('fb-welcome');
welcomeBlock.innerHTML = 'Hello, ' + data.first_name + '!';
});
}
}
FB.getLoginStatus(function(response) {
// Check login status on load, and if the user is
// already logged in, go directly to the welcome message.
if (response.status == 'connected') {
onLogin(response);
} else {
// Otherwise, show Login dialog first.
FB.login(function(response) {
onLogin(response);
}, {scope: 'user_friends,email,read_friendlists'});
}
});
FB.Canvas.setAutoGrow();
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
This happen on 6th of may 2015, before that it works fine..

Check this link and check your api version.
https://developers.facebook.com/docs/facebook-login/permissions/v2.3
As per this link
"If you want to access a person's friends who also use your app, you should use the user_friends permission.
This permission will also not help you invite a person's friends to use your app. To learn more about how to invite friends to an app, please see our FAQs.
This permission also does not give the list of friends who are part of a friendlist. It only gives access to the names of the lists.
This permission was called read_friendlists before v2.3.
Review
If your app requests this permission Facebook will have to review how your app uses it."

Related

How to check User facebook page like or not in v3.1

I have crated app on this link https://developers.facebook.com/ My app version is v3.1. I have use facebook api only scripting.
I want to check current user is like facebook page or not,If user is not like facebook page then request to like page,if user is liked then content are showing.
window.fbAsyncInit = function () {
FB.init({
appId:'xxx',
xfbml: true,
cookie: true,
status: true,
secret: 'xxx',
version: 'v3.1'
});
FB.Event.subscribe('edge.create',
function (href, widget) {
//alert('Ti piace ' + href);
//document.getElementById('fb-like').style.display = "none";
//var x = document.getElementsByTagName("button")[0].getAttribute("title");
// alert(x);
});
FB.api({ method: 'pages.isFan', page_id:'xxx' }, function (resp) {
console.log(resp);
if (resp) {
alert('You like it.');
} else {
alert("You don't like it.");
}
});
};
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
Error are occurred like this. I am tired please help me this problems.
erro_code:"104" erro_msg:"Incorrect signature(104),request_args:Arrar(7),error_subcode: "0"
Gating content behind likes is not allowed since many years.
The edge.create event has been removed. It would only allow to detect new likes anyway, not existing ones.
"pages.isFan" is very old, it would be /me/likes instead to get the Pages a user likes. And that only works if the user authorizes your App with the user_likes permission. You will not get that permission approved in the review process for like gating or incentivizing users to like your Page in any way.
TL;DR: Not possible and not allowed.

Facebook Async load error with another method

I want to add facebook login to my website. I async load it, and when I check that the person is not logged into my website through facebook I call a function to register them, but I get an error saying my function does not exist... facebook is in an html file, and the method I'm calling (FaceRegister()) is in a javascript file with the same name. I presume this is because of the loading order? Any ideas how to solve this?
Code:
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '217518691989396',
xfbml : true,
version : 'v2.8'
}) ;
FB.AppEvents.logPageView();
$(document).trigger('fbload');
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
$(document).on(
'fbload',
function(){
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
// The response object is returned with a status field that lets the
// app know the current login status of the person.
// Full docs on the response object can be found in the documentation
// for FB.getLoginStatus().
if (response.status === 'connected') {
// Logged into your app and Facebook.
testAPI();
} else {
// The person is not logged into your app or we are unable to tell.
faceRegister();
}
}

FB.login not asking for permissions [duplicate]

This question already has answers here:
Facebook JS SDK's FB.api('/me') method doesn't return the fields I expect in Graph API v2.4+
(4 answers)
Closed 7 years ago.
I am trying to integrate FB login with my html website. I am using FB Javascript SDK version 2.5. The pop-up opens and ask the users for the userid and password but donnot ask for permissions like email, public profile, location etc although i have given the required permissions in the scope param. Below is my code.
HTML code:
<div id="btnFBLogin"> <img style="width: 35%"
src="assets/img/icons/facebookloginbutton.png" />
</div>
Initializing FB Javascript SDK and gets initialized on document load :
window.fbAsyncInit = function() {
FB.init({
appId : 'XXXXXXXXX',
xfbml : true,
oauth : true,
version : 'v2.5'
});
};
//Load SDK
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
Calling FB.login api:
$('#btnFBLogin').on('click',function(){
FB.login(function(response) {
console.log(JSON.stringify(response));
if (response.status === 'connected') {
// Logged into your app and Facebook.
FB.api('/me', function(response) {
console.log('Successful login for: ' + response.name);
});
} else if (response.status === 'not_authorized') {
// The person is logged into Facebook, but not your app.
document.getElementById('status').innerHTML = 'Please log ' +
'into this app.';
} else {
document.getElementById('status').innerHTML = 'Please log ' +
'into Facebook.';
}
}, {scope: 'public_profile,email'});
});
The response object returned after login by FB.api('/me', function(response) gives only full name of the user logged in. It doesn't give me the email id although i have send it in the scope parameter.
you need to pass requested fields in url like
FB.api('/me?fields=id,first_name,last_name,friends,email',function(response)

Facebook logout by javascript

I am developing a simple web game with my friends. I have integrated facebook login using the javascript sdk provided by FB. Basically, the first page of the web game is main.html, in which I added successfully a Facebook button using the code provided by Facebook:
<script>
// This is called with the results from from FB.getLoginStatus().
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
// The response object is returned with a status field that lets the
// app know the current login status of the person.
// Full docs on the response object can be found in the documentation
// for FB.getLoginStatus().
if (response.status === 'connected') {
// Logged into your app and Facebook.
window.location.href = "mode.html";
} else if (response.status === 'not_authorized') {
// The person is logged into Facebook, but not your app.
document.getElementById('status').innerHTML = 'Please log ' +
'into this app.';
} else {
// The person is not logged into Facebook, so we're not sure if
// they are logged into this app or not.
document.getElementById('status').innerHTML = 'Please log ' +
'into Facebook.';
}
}
// This function is called when someone finishes with the Login
// Button. See the onlogin handler attached to it in the sample
// code below.
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : 'xxx',
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v2.3' // use version 2.3
});
// Now that we've initialized the JavaScript SDK, we call
// FB.getLoginStatus(). This function gets the state of the
// person visiting this page and can return one of three states to
// the callback you provide. They can be:
//
// 1. Logged into your app ('connected')
// 2. Logged into Facebook, but not your app ('not_authorized')
// 3. Not logged into Facebook and can't tell if they are logged into
// your app or not.
//
// These three cases are handled in the callback function.
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
// Load the SDK asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// Here we run a very simple test of the Graph API after login is
// successful. See statusChangeCallback() for when this call is made.
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Successful login for: ' + response.name);
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + '!';
});
}
</script>
<fb:login-button scope="public_profile,email" onlogin="checkLoginState();">
</fb:login-button>
Once login is successful, the page would be directed to another html page. In that html page, I tried to add an Facebook logout button. Trying for some hours, in vain. The most frequent error obtained is something like "FB is underfined".
Finally I decided to download a .png of FB logout button and include this .png as src image to "make" a button by myself, still in vain, rather frustrating.
The code I included in that another html page is as follows.
<script>
// This is called with the results from from FB.getLoginStatus().
window.fbAsyncInit = function() {
FB.init({
appId : 'xxx',
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v2.3' // use version 2.3
});
// Load the SDK asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function fbLogout() {
FB.logout(function (response) {
//Do what ever you want here when logged out like reloading the page
window.location.reload();
});
}
</script>
<button id="fblogout" onclick="fbLogout();""><img src="src/logout_fb.png"> </button>
The error I retrieved from the Chrome console is "Uncaught ReferenceError: fbLogout is not defined"
Have you tried using the "Enable logout button" at the plugin page: https://developers.facebook.com/docs/plugins/login-button
That will give you a button like this:
<div
class="fb-login-button"
data-max-rows="1"
data-size="medium"
data-show-faces="false"
data-auto-logout-link="true" />
If you use that code, you will either see a Login or Logout button, depending on the state. This can be used with the normal FB SDK for Javascript.

Display facebook photos on a website to users who aren't logged in

I have a photo album I want to display on a website to anybody who visits. At the moment I'm using FQL to show the album but it only shows to me when I'm logged in to my account. Is there a way anybody knows of to authenticate a public user or even somebody without a facebook account to view the album?
Current code:
var fbAppId = 'xxxxxxxxx';
window.fbAsyncInit = function() {
FB.init({
appId : fbAppId, // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse page for xfbml or html5 social plugins like login button below
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function getPhoto() {
FB.api(
{
method: 'fql.query',
query: 'SELECT src_big, src FROM photo WHERE album_object_id = "[my album id]"'
},
function(response) {
if (!response || response.error) {
console.log(response.error);
} else {
console.log(response);
for (var i = 0; i < response.length; i++) {
$('#result').append('<img src=' + response[i].src + ' alt="" /> ');
}
}
}
);
};
If you are okay using a third party facebook widget, a simple solution without any programming knowledge to displaying facebook photos on a website to users who aren't logged in by using
<iframe src="http://facebookgalleria.com/gallery.php?id=nike&rows=4&margin=10&cols=3&width=170&font_size=11&title_color=000&hide_next_back=0&share_buttons=1&shape=rectangle&frame=1" scrolling="no" marginheight="0" frameborder="0" width="551" style="height: 769px;"></iframe>
Change 'nike' in the url to your facebook page username, copy the code and paste it on your html website editor and it'll display neatly. Or customize your gallery at http://facebookgalleria.com. However, if you display photos from your personal facebook account, you need to go to the website and connect with facebook first. Then you generate your code that will work on your website without your customers having to log in to see them.
Hope this helps.

Categories

Resources