Invite friends popup is struggling, if the user is not logged in - javascript

I have created an invite friends code, which is properly working if an FB user is logged in.
If I remember correctly, it also worked, when there were no active fb users, in this case it simply shown a fb login page and then it went to an invitation.
Currently the 'invite facebook friends' link is really struggling, if there aren't any active facebook users.
FB.ui({
appId: '"' + appId + '"',
method: 'apprequests',
display: 'iframe',
message: '"' + message + '"',
title: 'Send your friends an application request'
},
function (response) {
if (response && response.request_ids) {
FB.api(response.request_ids, 'delete');
}
});
Did I do something wrong, or is this a bug in the Facebook invitation?

It seems, I got an answer on the Facebook bug site. However, it should help anybody , who has a lack of FB api knowledge . The documentation didn't show this example:
If there aren't any active fb session , it just open a login screen.
Finally I just realised what happened:
It doesn't show a login screen , if you use an IFRAME.
Do not use that!!
Thank you for Noorin Ladhani.
<script>
document.getElementById('send-to-many').onclick = function() {
FB.ui({
method: 'apprequests',
message: 'Visit my page'
}, Log.info.bind('send-to-many callback'));
}
</script>

Related

Facebook share return empty data even user logged in App

I'm building application have function when use share on facebook they will get
point from this action. By check this, I will check if facebook response post_id
but it return empty for me event user logged in app like with scrope
"publish_actions". I searched around but I cant see any thing help? This is my
code
FB.login(function(response) {
if (response.authResponse) {
console.log(response)
FB.ui({
method: 'share',
href: url_here,
}, function(response) {
console.log(response);
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, { scope: 'publish_actions', return_scopes: true });
Any suggestions?
Thanks.
What you are trying to achieve is not allowed and not possible. You will never get publish_actions approved for this, because you must not reward users in any way for sharing something. You need to read the platform policy: https://developers.facebook.com/policy/
4.5: Only incentivize a person to log into your app, enter a promotion on
your app’s Page, or check-in at a place. Don’t incentivize other
actions.
I've just find the issue. I used old app Id that I build before. So I create new facebook app and point it to current website I'm building. It's work perfect
Thanks guys for rep

Notification not sending to facebook friend

I have created an application where i am trying to invite friends via facebook invite friends js method but all working fine but no notification sent to that friend.
My Application Link: http://www.huzoorbux.com/fl/app/android/www/homepage_nopost.html
My Code:
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.api(
"/me/invitable_friends",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
if(top.location != self.location) {
top.location = self.location
}
FB.init({
appId:'228877127299395',
cookie:true,
status:true,
xfbml:true
});
function FacebookInviteFriends()
{
FB.ui({
method: 'apprequests',
message: 'Join My Job Buddy'
});
}
</script>
<div class="connectbutton5" id="ol">Invite Friends</div>
App Requests are for games only, that may be the reason. And always use a callback function for error handling, maybe you are missing an error:
FB.ui({method: 'apprequests',
message: 'YOUR_MESSAGE_HERE'
}, function(response){
console.log(response);
});
Also:
The invitable_friends API is only available for games that have a Facebook Canvas app implementation using version 2.0 of the Graph API.
Source: https://developers.facebook.com/docs/games/invitable-friends/v2.1
If you want to invite someone to a website, use the Send and Share Dialogs and Buttons. You don´t even need to authorize the user for them.

Javascript code shown when I share a link to website on facebook

When sharing some links on facebook(either programatically or manually), javascript code is being shown in the post.
Thus my question is more related to how to fix my website, so that, when posting link to facebook, javascript code doesn't show in the facebook post.
Forexample try posting this link:
http://djuice.com.pk/discounts
You'l see javascript code(which is present on the shared page) in the facebook post.
You are should set description param for sharing button. For example:
FB.ui(
{
method: 'feed',
name: 'The Facebook SDK for Javascript',
caption: 'Bringing Facebook to the desktop and mobile web',
description: (
'A small JavaScript library that allows you to harness ' +
'the power of Facebook, bringing the user\'s identity, ' +
'social graph and distribution power to your site.'
),
link: 'https://developers.facebook.com/docs/reference/javascript/',
picture: 'http://www.fbrell.com/public/f8.jpg'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);

publish_actions in scope not triggering second dialog

I have the following javascript code to login to my website using facebook
FB.login(function(response) {
if (response.authResponse) {
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
//proceed to login
} else {
//login failed
}
}, {scope: 'publish_actions, email, user_birthday',
appId : 'myAppId',
cookie : true});
The first dialog shows up fine requesting their email and birthday. However, the second (optional) dialog does not show up requesting to post to their profile. I have seen this on many sites, but it does not show up on mine.
Is there any other steps I need to take to show this? I have tried publish_stream as well.
EDIT: Still no answer. I am testing with a Facebook account that was previously connected, but I removed the app from my Facebook profile and connected again. That should ensure that the second dialog comes up, but it doesn't.
I once read in the facebook documentation you must request this permission in the init function.
try
window.fbAsyncInit = function () {
FB.init({
appId: 'Id_App',
status: true,
xfbml: true
}), { scope: 'publish_actions' };
};

app domain in facebook [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I am trying to make a web page to post status in facebook but with scripts on FB webpage I am not able to do it.
<!DOCTYPE html>
<html>
<body>
<div id="fb-root"></div>
Post To Wall
<script src="//connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({ appId: 'XXXX',
status: true,
cookie: true,
xfbml: true,
oauth: true });
function postToWall() {
FB.login(function(response) {
console.log(response);
if (response.authResponse) {
FB.ui({
method: 'feed',
name: 'Facebook Dialogs',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
});
} else {
alert('User cancelled login or did not fully authorize.');
}
}, {scope: 'user_likes,offline_access,publish_stream'});
return false;
}
</script>
</body>
</html>
Of course I use the correct appId of my application. I have the applicacion in sandbox mode because I still has nothing, just this script. My webpage will just has this part to post and nothing else related to facebook.
I am testing it in my compunter with xampp. So I guess in facebook app domain I have to write it but everything I tried (localhost, localhost/faceapp/...) fail. For example, I get this:
Error
App Domains: http://localhost/appFace should not contain protocol information.
When the prompt appears, you can write your user and your password but the next window tells you that the webpage is not allowed in app configuration and something else. I read it in spanish so I don't know the exact sentence in english.
I have found many answet about this but most of them are from the previous version of the api ¨(which has changed since that) and the others tells to use localhost or so, and I can't save the changes in fb app writing that.
In your app settings in FB, put App domain "localhost" and if your are using Login With FB, then in Site URL enter http:// localhost / (without space) or if you have created any virtual host, enter that...

Categories