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...
Related
I am working on a mobile application, using Cordova. I want to implement the Deezer Javascript SDK. Everything is fine except for one thing: I cannot implement the login method (DZ.login).
DZ.login method uses the oauth2 protocol. When I call it, I access the Deezer connection interface, so I can write my credentials. But it comes to redirection, I only get a white screen.
The fact is that I don't know, and I did not find what redirect_url to use.
Indeed, when you register an application on Deezer Developers, you have to give an application domain, and a redirect uri. I tried lots:
localhost / http: //localhost/index.html (Gives me a white screen)
com.company.app / http: //app.company.com/index.html (Gives me an invalid redirect uri)
company / "http: //company.com/index.html" (Gives me an invalid redirect uri)
(I put spaces between http: and // as my reputation is not high enough to post more than 2 links)
This is the SDK initialization function:
initDeezerSDK: function() {
DZ.init({
appId : 'myAppId',
channelUrl : 'http://localhost/channel.html',
player: {
onload: function () {
alert("yo");
}
}
});
},
This is the Deezer login function:
DZ.login(function(response) {
if (response.authResponse) {
DZ.api('/user/me', function(response) {
$('deezer-name').val(response.name);
window.location.href = '#profile';
alert(response.name);
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
},
{
perms: 'basic_access,email'
});
Thanks for your help guys, this part is really critical for my app... Cheers!
Deezer developers interface
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
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.
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.');
}
}
);
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>