FB.login() causes Error 191 in any IE (Internet Exploder) - facebook

I have searched this problem for long now but all answers have not worked so far.
The code that calls for login:
FB.login(function(response) {
if (response.authResponse) {
FB.api('/me', function(response) {
document.getElementById("nimi").value = response.name;
document.getElementById("email").value = response.email;
FB.ui(
{
method: 'stream.publish',
attachment: {
name: 'Jõulupidu Maikrahv restoranis!',
caption: 'Broneeri firma jõulupidu hubases Maikrahv restoranis! Kingime Uusaasta pidulaua 10- le ja romantilise õhtusöögi kahele! ',
media: [
{
"type": "image",
"src": "http://ssl.advert.ee/maikrahv-joulupidu/maikrahv.jpg",
"href": https+"://ssl.advert.ee/maikrahv-joulupidu/"
}]
},
href: https+'://ssl.advert.ee/maikrahv-joulupidu/',
action_links: [
{ text: 'Maikrahv', href: https+"://ssl.advert.ee/maikrahv-joulupidu/" }
]
},
function(response) {
if (response && response.post_id) {
var ajaxresp = jagame_fbajax();
} else {
fb_alert("Teade!", "Postitust ei jagatud ja ei osale loosimises.");
}
}
);
});
} else {
fb_alert("Viga!", "Kuna õiguseid ei jagatud, ei saanud Sind osalemises kahjuks kirja panna")
}
}, {scope: 'email'});
}
Only IE gives this error
An error occurred with Jõulupidu Maikrahvis. Please try again later.
API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: Invalid redirect_uri: Antud URL ei ole rakenduse konfiguratsiooni poolt lubatud.
Application settings:
App Domain: advert.ee ssl.advert.ee
Website:
Siute URL: http://ssl.advert.ee/maikrahv-joulupidu/
App on Facebook:
Canvas URL: http://ssl.advert.ee/maikrahv-joulupidu/
Secure Cavas URL: https://ssl.advert.ee/maikrahv-joulupidu/
Canvas Page: http://apps.facebook.com/maikrahv-joulupidu
Page Tab:
Page Tab Name: Jõulupidu Maikrahvis!
Page Tab URL: http://ssl.advert.ee/maikrahv-joulupidu/
Secure Page Tab URL: https://ssl.advert.ee/maikrahv-joulupidu/
Reported bug also:
https://developers.facebook.com/bugs/258868920826496
Please help. App must go live tomorrow :(

remove the channelUrl parameter from the fb init. IE reads the javascript incorrectly and puts the channel URL in the redirect_uri query var and it breaks the whole process.

Jacob rights.
I put this code:
if ( $.browser.msie ) {
FB.init({
appId : 'APP_ID',
status : true,
cookie : true,
oauth : true,
xfbml : true
});
} else {
FB.init({
appId : APP_ID,
channelUrl : '//example.com/channel.php', // Channel File
status : true,
cookie : true,
oauth : true,
xfbml : true
});
}
and solved the problem.

Related

Facebook API Error Code: 191 with specified url

I've found some questions about this mistake, this for example.
I made changes according to them. I've added my url as site in my app on facebook which has domain name the same called as my site. Now I use this func on click on share link of my site:
var url = 'http://callbackyou.ru/';
var title = 'kkkkkk';
var description = 'description';
var image = 'http://callbackyou.ru/img/callbackyou.ru.jpg';
function fb_share()
{
FB.init({
appId : '***',
xfbml : true,
version : 'v2.5'
});
FB.ui( {
method: 'feed',
redirect_uri: 'https://callbackyou.ru/',
name: title,
link: url,
picture: image,
caption: description
}, function( response ) {
if ( response !== null && typeof response.post_id !== 'undefined' ) {
call_soc();
}
} );
}
And this doesn't work I get mistake:
API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: redirect_uri is not owned by the application.

API Error Description: Session key invalid or no longer valid (error 102)

I cant figure out why facebook publish is not working on this site
I get
API Error Code: 102
API Error Description: Session key invalid or no longer valid
Error Message: Iframe dialogs must be called with a session key
While calling the stream.publish method as iframe
<script type="text/javascript">
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol
+ '//connect.facebook.net/fr_FR/all.js';
document.getElementById('fb-root').appendChild(e);
}());
window.fbAsyncInit = function()
{
FB.init({ appId: '303380259758621',
status: true,
channelUrl: 'http://www.crabegame.com/channel.php',
cookie: true,
xfbml: true,
oauth: true});
}
function PublishStream(score)
{
FB.ui(
{
method: 'stream.publish',
display : 'iframe',
message : '',
attachment:
{
name: 'CrabeGame',
caption: 'Essaye de battre mon score sur le Crabe Game !',
description: "J'ai réalisé un score de " + score + "points au Crabe Game !",
href: 'http://www.crabegame.com',
media:
[
{
type: 'image',
src: 'http://crabegame.com/media/crabe_fb.png',
href: 'http://www.crabegame.com'
}
]
},
action_links:
[
{
text: 'Play Crabe Game',
href: 'http://www.crabe-game.com'
}
],
user_message_prompt: 'Publier sur votre mur'
},
function (response)
{
if (response && response.post_id)
{
}
}
);
}
</script>
This means that you have no current user. Try this in order to call PublishStream:
FB.login(function(response) {
if (response.authResponse) {
PublishStream();
} else {
console.log('Not logged in');
}
});
you don´t need a logged in user, just remove display: "iframe", worked for me. it will still show in an iframe, but without error. don´t ask me why, with 1:1 the same app settings it works WITH the display value in another app of mine...at least that worked for me with the apprequest dialog, might be the same here.
and i would use "feed" instead of "stream.publish".
see here: https://developers.facebook.com/docs/reference/dialogs/feed/
also: Using Like Button and FB.ui (apprequests) On the Same Page Conflicts

Facebook API: send message to friends works for only test/admin users

I'm working on a website, as part of that we are allowing users to invite their friends. Using following code
// assume we are already logged in
FB.init({appId: 'xxxxxxxx49030', xfbml: true, cookie: true});
function sendInvites(fb_ids) {
var link_url = "<?php echo base_url()?>invited/?code=100627510332492694";
FB.ui({
method: "send",
to: fb_ids,
name: "Join example.com",
description: "hello",
picture: "http://www.example.com/images/logo-orange.png",
link: link_url
}, function(response) {
alert(response)
if (!response){
return;
}
$.post("/invite/new/", {
fb_ids: fb_ids
}, function(data) {
if (data.status == "success") {
alert(data.status);
} else {
alert(data.message);
}
}, "json");
});
}
Don't understand what's missing.
Fbids should be an array and i missed it. It's working now.

FB.login Error in Internet Explorer

I am using connect-js (FB.login) to login users to share my page, in standard way. In all normal browsers (chrome, firefox, opera) it pops up a window with permissions request (everything is fine). But in Internet Explorer (7 and 8, didn't test in 6) it pops up window that says: "An error occurred with [myapp]. Please try again later."
This is my code:
<div id="fb-root"></div>
<script language="javascript">
var nombre = "";
var pic_big = "";
FB.init({
appId : '161599150607341', // App ID
channelUrl : '//emocionesverde.com/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 conectarse() {
FB.login(handleSessionResponse, {
scope: 'publish_stream, user_about_me'
});
}
function handleSessionResponse(response) {
if (response.authResponse) {
FB.api('/me', function(response) {
//console.log(response.name);
window.nombre = response.name;
getUserPic(response.id);
});
}
}
function getUserPic(uid) {
FB.api('/me?fields=picture&type=large', function(response) {
//console.log(response.picture);
window.pic_big = response.picture;
publicar();
});
}
function publicar() {
FB.ui({
method: 'stream.publish',
message: '',
attachment: {
name: 'Emoción es Verde',
caption: window.nombre + ' midió el impacto de sus acciones verdes. Te invitamos a conocer acciones para mantener el planeta verde con Emoción es Verde',
media: [{
type: 'flash',
swfsrc: 'http://mainteractivetools.com/erik/mifb/emocionesverde/Prueba.swf?pic=' + window.pic_big + '&nombre=' + window.nombre,
imgsrc: 'http://mainteractivetools.com/erik/mifb/emocionesverde/telefonica1.jpg',
expanded_width: '450',
expanded_height: '258'
}],
href: 'http://www.emocionesverde.com'
},
action_links: [{
text: 'Emoción es Verde',
href: 'http://www.emocionesverde.com'
}],
user_message_prompt: 'Escribe un comentario'
}, function (response) {});
}
$('#swfmapsdiv').css('visibility', 'hidden');
</script>
Have you tried adding p3p headers? It's an IE thing and clears up a lot of problems. However cryptic the codes are. What Facebook is essentially trying to do is share cookies across domains, which is a security flag. You need to say it's ok.
The issue could be in channelUrl, try to have the whole path there i.e http://emocionesverde.com/channel.html
Also login into facebook as app developer - the error message will be more detailed

Facebook code to prompt for stream publish with in application

I have a bit confusion using facebook API. I am using a code that is working out side of facebook but not in facebook application canvas page.
I have bit idea but not sure. Can anybody let me know the reason behind this and the code that will run in facebook application.
What is difference you run code using application like
http://apps.facebook.com/exampleAPP/test.php
or normal url
http://www. example.com/example/test.php
http://www. example.com/example/ is the canvas URL
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : '115454544334343454',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.ui(
{
method: 'stream.publish',
attachment: {
name: 'JSSDK',
caption: 'The Facebook JavaScript SDK',
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.'
),
href: 'http://fbrell.com/'
},
action_links: [
{ text: 'fbrell', href: 'http://fbrell.com/' }
]
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
</script>
I'm fairly sure stream.publish is deprecated and unsupported. What you want instead is the Feed dialog.