on click triggering of fb share dialog box not working - facebook

I have one online treasure hunt website.When a user enter a correct answer it will show a page which has a continue button. When we click that continue button a facebook share dialog box will appear. The onclick function for that button is as follows.
<div class="row" >
<div class="text-center">
<?php if($result==TRUE): ?>
<a onclick="FB.ui({
method: 'share',
href: '',
quote: 'Successfully Completed Level <?php echo $level-1 ?> . An Exciting Online Treasure Hunt',
hashtag: '',
}, function(response){
location.href ='<?php echo base_url() ?>';
});" class="buttonfb btn btn-lg btn-success" role="button">Continue</a>
<?php else: ?>
Try Again
<?php endif; ?>
</div></div></div>
Here it will trigger a fb share dialog box which makes it able for user to share his achievement on fb. But the error is that when the dialog box for share appears an error message is written in dialog box. It is as follows
Can't load URL: The domain of this URL isn't included in the app's
domains. To be able to load this URL, add all domains and sub-domains
of your app to the App Domains field in your app settings.
This is my script
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'here i set my app id',
xfbml : true,
version : 'v2.8'
});
FB.AppEvents.logPageView();
};
(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'));
</script>
I already have added app domains and URL correctly in my Facebook app. Also, I have a login with Facebook button in my home page. The login with Facebook button is working fine, but the share dialog box shows this error.
Please help me.

Related

Facebook login button broke?

I have a couple of facebook buttons and they appear as plain text. I have no clue why. It happened all of a sudden, I didn't change the code. All browsers show it as plain text.
My code is:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : '<?php echo AppInfo::appID(); ?>', // App ID from the app dashboard
channelUrl : '//<?php echo $_SERVER["HTTP_HOST"]; ?>/channel.html', // Channel file for x-domain comms
status : true, // Check Facebook Login status
xfbml : true // Look for social plugins on the page
});
// Additional initialization code such as adding Event Listeners goes here
};
// 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_GB/all.js#xfbml=1&appId=MY_APP_ID";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<ul>
<li><fb:login-button scope="user_map" id="get_map" onclick="self.location=http://localhost:8080/savefunctions.php?runFunction=getLikes">Get Map</fb:login-button></li>
<li><fb:login-button scope="user_groups" id="get_acc" onclick="self.location=http://localhost:8080/savefunctions.php?runFunction=getLikes">Get your account info</fb:login-button>
<div class="fb-login-button" data-show-faces="true" data-width="200" data-max-rows="1">Gica</div></li>
<li><fb:login-button scope="user_apps" id="like_acc" onclick="self.location=http://localhost:8080/savefunctions.php?runFunction=getLikes">Get apps</fb:login-button></li>
<li><fb:login-button scope="user_groups" id="get_all" onclick="http://localhost:8080/savefunctions.php?runFunction=getLikes">Get All</fb:login-button></li>
</ul>
Please ignore things in onClick.
Please notice that I tried both <fb:login-button> and <div class="fb-login-button">. They both appear as plain text.

Use FB Send button

I am new to FB integration. I want to use FB send button, to send invites to my facebook friends.
Below is the code I used.
<div>
<span> To choose friends from your facebook list , click here : </span >
<div id="fb-root"></div>
<script>(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#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-send" data-href="http://61.12.14.179/fb_test.html"></div>
</div>
I get a fb send button. But when I click on the fb send button, select my friends to send invites, it displays as "We encountered the following error while sending your message" and no error message is displayed.
Message is also not sent.
Any help?
Try Something like:
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : 'your_app_id',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
</script>
<fb:like href="your_url" send="true" width="450" show_faces="false" font=""></fb:like>
This will show the send button that works.

Facebook shows blank screen after login (facebook js api)

<body>
<script>
// Facebook Init
window.fbAsyncInit = function() {
FB.init({
appId : '...MYID...', // App ID
channelUrl : 'channel.html', // 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
FB.Event.subscribe('edge.create',
function(response) {
alert('You liked the URL: ' + response);
}
);
};
</script>
<div id="fb-root"></div>
<script>(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/de_DE/all.js#xfbml=1&appId=...MYID...";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div id="player"></div>
<div id="main">
<div id="facebook" style="height:30px;">
<div class="fb-like" data-href="http://www.MYURL.com/about" data-send="true" data-width="450" data-show-faces="true"></div>
</div>
Can somebody help? I am php programmer myself and just stuck with JS... I also considered the Php api, but actually it used to work, now it hangs all of sudden.. not sure what I did :(
Thanks!
Please see the Facebook developer site. It would be a good place to track as this is possibly not you. I'm having the same issue and I'm using FBML tags and not iFrame or HTML5.
https://developers.facebook.com/bugs/347759798609016
Something else to try is to try logging in, kill that window, then refresh the page. For me at least the "Like" button works after the refresh. So the login is successful, but the response from Facebook isn't.

Cannot set ref on like button

Im trying to add a like button to my web app that is currently in development on localhost.
Ive set the ref attribute for fb:like and whilst i can like my websites page and see it in on my test-users facebook wall, the link posted does not contain any params such as fb_ref etc. Even clicking the link and checking my servers logs shows no params were sent.
I dont know what im doing wrong. Due to extensive testing facebook requires me to "confirm" I want to like something each time I click on the like button (a measure to thrwart spammers I believe). Does that have anything to do with it? I also turned on sandbox mode.
here is the button
<fb:like href="localhost:3000" ref="atrackingcode" send="false" show_faces="false" width="450" class=" fb_edge_widget_with_comment fb_iframe_widget"></fb:like>
here is the sdk intialization
<div id="fb-root"></div>
<script src="//connect.facebook.net/en_US/all.js"></script>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'SECRET-SO-BOO-HOO',
channelUrl : '//localhost:3000/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>

Issues with Facebook and Symfony 1.4

New Facebook and Symfony 1.4 developer with a couple of issues.
First off, I am having an issue with getting the Add to Timeline button to appear on my page where I need it. My site seems to show a Facebook loading image, then after the apparent loading no button is displayed. I've looked around at many different sites (including the FB tutorial for Open Graph), all saying to place the scripts after the opening body tag. I have placed it in my layout.php file so that I do not have to put it in multiple places:
layout.php
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" xmlns:fb="http://ogp.me/ns/fb#" xmlns:og="http://ogp.me/ns#">
....
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'APP_ID',
status : true,
cookie : true,
xfbml : true,
oauth : true
});
};
(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#xfbml=1&appId=APP_ID";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div id="container">
I have already replaced APP_ID where appropriate and placed the Add to Timeline button in a view:
viewSuccess.php
<?php // Facebook Post-to-Timeline Button for this user's created recipe ?>
<?php if($recipe->getUserId() == sfUserTools::getConnectedUser()->getId()): ?>
<fb:add-to-timeline show-faces="false" mode="button"></fb:add-to-timeline>
<?php endif ?>
I'm not sure if its an issue with where the JSSDK script is placed, or if Symfony is not seeing something in the view page. Note, I do not yet have our app's actions and objects setup for Open Graph, posting to the timeline is not my concern at this time. Any ideas or advice for a newbie?
Did you try to pass the access_token or the perms on the FB.init ?
FB.init({
appId : "<?php echo sfConfig::get('app_facebook_api_key') ?>",
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : false, // parse XFBML
perms : 'read_stream, publish_stream',
access_token : "ACCESS_TOKEN_HERE",
frictionlessRequests : true
});