Facebook API targeting only canada - facebook

I am having some trouble getting the FB api's targeting feature to work. I want to target only Canada but I can't seem to figure out what the documentation is asking of me. This is what I have tried
FB.api(
'/' + pageId + '/live_videos',
'POST',
{access_token: accessToken,
description: document.getElementById("streamDescription").value,
title: document.getElementById("streamName").value,
targeting: {excluded_countries: ["840"]}
}
currently this is outputing
"(#100) The targeting param has invalid values for: excluded_countries"

Here is how you do it
FB.api(
'/' + pageId + '/live_videos',
'POST',
{access_token: accessToken,
description: document.getElementById("streamDescription").value,
title: document.getElementById("streamName").value,
targeting:{geo_locations:{countries:["CA"]}}
}

Related

How can I post feed to other user wall by javascript sdk

I've succeed to publish feed to my wall but not to another user wall
I've defined both 'from' and 'to' variable
but I got error message when publishing the feed which said
"An error occurred. Please try again later."
here is my code when publishing
var obj = {
method: 'feed',
link: 'http://apps.facebook.com/' + fb_app_id,
picture: app_url + 'icon/test.png',
from: facebookid1,
to: facebookid2,
name: 'Test App',
caption: 'This is a test!!',
description: 'Test to publish feed to other user wall'
};
function callback(response) {
// Callback after feed posted...
}
FB.ui(obj, callback);
I don't know what is wrong or their are any extend permission required ?
try this code
FB.ui( {
method: 'feed',
name: name,
link: link,//Link is any link you want to post
picture: picture,
caption: caption,
description: redemption,
message: message,
to: page_id,
from: page_id
},
function (response) {
if (response && response.post_id) {
alert(response.post_id);
} else {
}
}
);
also if a user have set privacy that no once can post anything on their's wall, you'll unable to post in this case

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.

Login repeats after authenticate, if i try to send a friends request

Im trying to build a 'cheer action' for my app. It is a game in iPhone, so I want to post a 'welcome message' in the users wall (I will need 'public_stream' permission) and then invite his friends to visit my webpage.
Here my question.. I authenticate the user using:
_url = "http://www.facebook.com/dialog/oauth/?client_id=" + app_id + "&redirect_uri=" + app_net_folder + auth_response_uri + "&state=" + session_id;
I get response in my uri, and then I get the access_token, user_id, etc.
Then I post a message in his wall in this way:
_url = "https://www.facebook.com/dialog/apprequests?app_id=" + app_id;
_url += "&message=" + string_ToUrl(String_ToHTML(request_msg));
Now I want to invite his friends (using a multi friend list dialog). To do it, I can only use JavaScript FB.ui. In this way:
FB.init({appId : app_id, logging : false, frictionlessRequests: true, oauth : true});
FB.ui({method: 'apprequests', message: msg, title: title}, requestCallback);
When I do it, a window is opened asking me again for the user's login.. but my user has been already authenthicated. So I dont know how to say to FB in JavaScript that my user has been alredy authenthicated! (I even have the access_token, but I don't know how to use it in JavaScript functions).
Someone knows what am I doing wrong? or how to do those two actions asking just one time for the user's login?
Thanks!!
if you are already log in, you can get login user id using below code
var userId = FB.Facebook.apiClient.get_session().uid;
if(userId > 0 || userId != '')
{
alert('user is already log in');
}
hope it's helpful to you

how do I get a 're-share' option to show up in my app's dialog.feed post

I have a fb app that has an html anchor tag which uses href = http://www.facebook.com/dialog/feed...
it works fine.
but when the post shows up in the feed, it only has a 'comment' and a 'like' option beneath it.
however, I see some other posts in my feed that also have a 'reshare' option.
how do I get that?
thanks,
Shannon
I am having a similar problem; the user can post the photo to their own (or someone else's wall) but only the like and comment options appear with the post.
FB.init({appId: "xxxxxxxxxxx", status: true, cookie: true});
function fbShare(pic) {
event.preventDefault();
//call the API
var obj = {
method: 'feed',
link: 'http://localhost/users/#/gingles/1680/',
picture: 'http://c711249.r49.cf2.rackcdn.com/thumbs/1680_19.png',
name: 'gingle social transparancy',
caption: __video.title,
redirect_uri: 'http://www.gingle.tv/close-page',
description: 'Watch this video on gingle.tv',
};
function callback(response) {
console.log(response);
}
FB.ui(obj, callback);
}
The option to post comes up just fine
But once posted, no share option exists
(screenshots were filtered out by my newness to this site)
I have spend quite a while pouring through the facebook documentation but I can't see a solution.
To make this more fun, when using the URL method, I was getting a share option, but the photo would be lost. but after all my experiments with the FB.ui rolling back to the URL approach will not share.
var fbUrl = 'https://www.facebook.com/dialog/feed?app_id=xxxxxxxxxxx&' +
'link=http://' + encodeURIComponent(window.location.host + '/users/#/' + __video.username + '/' + __video.id) + '&picture=' + $(this).find('img').attr('src') +
'&name=gingle%20|%20social%20transparency&' + 'caption=' + __video.title +
'&description=Watch%20this%20ideo%20on%20gingle.tv&' +
'redirect_uri=http://www.gingle.tv/close-page';
$('#screenshot_social').html('<a href="' + fbUrl + '" target=_blank>Share on Facebook</a>');
Any direction or ideas would be most welcome.

How to use the user object in Facebook dialog using Facebook javascript SDK?

I want have feed dialog in which i also want to use his First name or user object.I'm using FB.Ui method.
<script>
var publish = {
method: 'stream.publish',
display: 'popup', // force popup mode
attachment: {
name: 'I visted this Appp',
caption: 'The Facebook Connect 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/'
}
};
FB.ui(publish, Log.info.bind('stream.publish callback'));
</script>
As you can see in caption it is ' i visited this app'.I want to change it to the Facebook user's first name..i.e 'first_name visted this app'..Anyone can help me out
To get info about the user, you would first need to have them authenticate with your application (no extended permissions would be needed as name is considered "basic" information). Then you could then call a FQL query with the javascript api to get their name and then use that to populate the message.
Authenticate user:
<fb:login-button autologoutlink="true"></fb:login-button>
Get users name:
FB.api(
{
method: 'fql.query',
query: 'SELECT name FROM user WHERE uid='+FB.getSession().uid
},
function(response) {
alert(response[0].name);
}
);