Facebook API Error Code: 191 with specified url - facebook

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.

Related

How to hide facebook post link/caption parameter from facebook javascript sdk

I'm using Facebook JavaScript SDK to post on different Facebook's users Pages, from my custom HTML form,
My HTML FORM contains Following fields
title=>textbox,
Link url=>textbox,
picture=>textbox,
message=>textarea
but the issue I'm facing is that when user did not entered LINK URL in field(blank), and entered Picture URL in picture URL fieldbox then facebook showing PICTURE HOST name in wall instead showing blank or no link URL / picture URL.
CODE which I am using for post my status on pages
FB.api('/' + d + '/feed', 'post', {
message: my_message,
link: url,
name: title,
picture: picUrl,
description: desc,
access_token: b.access_token
}, function (a) {
if (!a || a.error) {
alert('Error occured')
} else {
alert('Message Posted Successfully.')
}
})
link: url
picture: picURL
I tried to submit by comment "link" parameter but still facebook showing picture host URL address on wall.
so i need to know how to stop showing picture host URL address on wall if user did not submit link URL
In the Facebook post you can refer this link as an Caption you just need to keep some space into the Caption Parameter. If you are using string.empty then it will print the you IP Address/Domain Name.
Here i am providing you the sample Code for that...
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function () {
FB.init({
//Get your Facebook API Key from Web.config
appId: '<%=ConfigurationManager.AppSettings["FB_API_KEY"].ToString() %>',
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
xfbml: true // parse XFBML
});
};
(function () {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
you need to create div to add the script into it.
Now, I am Calling the postToFacebook() function from the ServerSide, you can do that as per your requirement. So, Here is the function of that.
function postToFacebook() {
var POST_NAME = "Post Name";
var POST_DESCRIPTION = "Post Description";
var POST_MESSAGE = "";
//Here I am Leaving some space in the Caption to avoid link name
var POST_CAPTION = " ";
var body = 'Reading Connect JS documentation';
FB.login(function (response) {
if (response.authResponse) {
FB.api('/me/feed', 'post', { body: body, message: POST_MESSAGE, caption: POST_CAPTION, name: POST_NAME, description: POST_DESCRIPTION, picture: document.getElementById('hfImageURL').value }, function (response) {
if (!response || response.error) {
//alert(response.error);
alert('Image is not posted.');
} else {
alert('Image is posted.');
}
});
}
}, { scope: 'offline_access,publish_stream' });
}
I am storing the Image URL into the HiddenField having ID hfImageURL, and give that to the picture property of the Post.
So that's it you can check that code... Working fine for me...
Have a Nice DAY...

I tried to use facebook feed dialog but it's not work

Just trying to post feed to my wall, but got errors message
An error occurred. Please try again later.
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.
here is my code
var app_url = http://xxx.xxx.xxx.xxx;
var fb_app_id = xxxxxxxxxx;
// When init
FB.init({
appId: fb_app_id,
status: true,
cookie: true,
xfbml: true,
frictionlessRequests: true,
useCachedDialogs: true,
oauth: true
});
// When posting
FB.ui({
method : 'feed',
link : 'http://apps.facebook.com/' + fb_app_id,
redirect_uri : app_url + 'facebook/index.php',
picture : app_url + 'icon/fb_feed_lvup.png',
name : 'My Game',
caption : 'Player level up to ' + level + '!!',
description : 'Congratulation :D'
},
function callback(response) {
// Callback after feed posted...
console.log('publishStory UI response: ', response);
});
I doesn't know that it's related to my app setting which not set "App Domains" or not ?
I can't set it because the host doesn't have Domain name I'm just using IP address to set an URL setting.
Try this-
Copy the Site URL from the app settings to the redirect_url and then check if it works.
I checked, else everything is fine.

Facebook Feed Dialog Returns API Error Code: 191

In my Facebook App I'll always get the following error :
An error occurred. Please try again later.
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.
I just want to feed a post via button my code is
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'https://mydomain.com/',
picture: 'https://mydomain.com/img/feed.png',
name: 'BLABLADialog',
caption: 'UeberschriftBLABLA',
description: 'DescriptionBLABLA',
show_error: true
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
my Canvas-URL is "http://mydomain.com/"
my Secure Canvas-URL is "https://mydomain.com/"
my Tab-URL is "https://mydomain.com/tab.php"
my Secure Tab-URL is "https://mydomain.com/tab.php"
my Website with Facebook Login SITE URL is "https://mydomain.com/"
so what I am doing wrong ?
You need to include a redirect_uri in your var obj array. On the Feed Dialog documentation, redirect_uri is specified as:
The URL to redirect to after the user clicks a button on the dialog. Required, but automatically specified by most SDKs.
So it must be specified, and it must a URL that falls under the Site URL of your app.

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

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.

Extracting user id from Facebook Javascript SDK session object

I am using Facebook's Javascript SDK "FB.ui" to pull up an OAuth dialog. Once you click allow, I need to capture the session object, extract the user id and use it further in my script. For some reason I cannot get this working properly, I keep getting undefined, even though the session does exist.
<script src="http://connect.facebook.net/en_US/all.js"></script>
<div id="fb-root"></div>
<script type="text/javascript">
FB.init({
appId : '***************',
status : true,
cookie : true,
xfbml : true
});
FB.getLoginStatus(function(response) {
if (response.session) {
//do something
} else {
FB.ui({
method: 'oauth',
display: 'page',
scope: 'email',
perms: 'email'
},
function(response) {
alert(response.session.uid); //returns underfined
});
}
});
</script>
To get the userID:
FB.getLoginStatus(function(response) {
alert(response.authResponse.userID);
});
When you login from login button of facebook then it stores cookies in your system that contains your access token that is also unique. That cookies contains your facebook id also.
Check your response. I bet it says something like "display" must be one of "popup", "iframe" or "hidden". Apparently the oauth dialog cannot be called with the default "page" display. And display: 'iframe' requires that you include an access_token, which is why you're calling the oauth dialog in the first place >:l .
I don't think FB.ui can currently be used to get the oauth dialog, unless you want to use a popup, which most everyone has blocked nowadays.
So I got this to work as I would like. This may not be the best way, but after much digging around and frustration I hope this could help somebody with the same question get on the right track.
JS source:
FB.getLoginStatus(function(response) {
if (!response.session) {
//initiate FB OAuth js popup dialog
FB.ui({
method: 'oauth',
display: 'page',
scope: 'email',
perms: 'email'
},
function(response) {
if (response.session) { //if permission Allowed
var thesession = response.session;
var thesession = eval('(' + thesession + ')'); //decode json
//POSTing to local file get.user_graph.php, to fetch user info
$.ajax({
type: "POST",
url: "get.user_graph.php",
data: "client_id=<?php echo $appId; ?>&client_secret=<?php echo $secret; ?>&sessions="+thesession.session_key+"&type=client_cred&uid="+thesession.uid,
dataType: "text",
success: function(user_graph){
var user_graph1 = eval('('+user_graph+')');
alert(user_graph1.name); //users name
alert(user_graph1.id); //users id
alert(user_graph1.email); //users email
alert(user_graph1.link); //users profile link
}
});
} else {
//if permission Not Allowed
}
});
}
});
get.user_graph.php source:
//exchange our session for an access_token
define('POSTURL', 'https://graph.facebook.com/oauth/exchange_sessions');
define('POSTVARS', 'client_id='.$_POST['client_id'].'&client_secret='.$_POST['client_secret'].'&sessions='.$_POST['sessions'].'&type=client_cred');
$curl_token = curl_init(POSTURL);
curl_setopt($curl_token, CURLOPT_POST,1);
curl_setopt($curl_token, CURLOPT_POSTFIELDS,POSTVARS);
curl_setopt($curl_token, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($curl_token, CURLOPT_HEADER,0);
curl_setopt($curl_token, CURLOPT_RETURNTRANSFER,1);
$token = curl_exec($curl_token);
$token_decoded = json_decode($token,true);
//get the user graph (personal info)
$user_graph = file_get_contents("https://graph.facebook.com/".$_POST['uid']."?access_token=".$token_decoded[0]['access_token']);
echo $user_graph;