Facebook app: change post-on-wall privacy - facebook

I am using this function to post on my own wall, and I would like to set the privacy of the post to FRIENDS. But it doesn't work. Always keeps the default app privacy (PUBLIC). How can I change this?
Thanks
function postToWall(message, header) {
FB.ui(
{
method: 'feed',
caption: header,
link: 'http://www.iflikeu.com',
picture: 'http://myapp.herokuapp.com/common/images/icon.png',
description: message,
privacy: {'value': 'ALL_FRIENDS'}
},
function(response) {
/*if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}*/
}
);
}

Your example is a call to FB.ui() which triggers the feed dialog - the user selects the privacy for such posts on a post by post basis
If you're posting directly via the API you'd be calling FB.api() where you can set the privacy per-post directly; using the Dialog the user can always choose post visibility, and the value in the selector defaults to their default privacy setting for your app

You can try to edit the Application settings : Configuring Permissions.
And set Default Activity Privacy: to public.

Related

Facebook share callback, more data?

I'm using a simple Facebook share dialog:
FB.ui(
{
method: 'share',
href: 'http://example.com'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.'+JSON.stringify(response));
} else {
alert('Post was not published.'+linkToShare);
}
}
);
When I get a success callback, all it gives me is the post id. Is there a way to get more data?
What I really want to know is how the page was shared e.g. Only Me, Friends or Public
Is this data out there anywhere?
If you want to know more, you need to use OAuth to get information about the web app using user.
Example:
FB.api('/me', function(response) {
console.log(response);
});
EDIT: Here you can find out more about to get information from a single post

Get post-id after FB.ui() share

I need to get post-id after user clicks on the share button. My code so far:
$("#share").click(function(e) {
e.preventDefault;
FB.ui({
method: 'share',
href: 'developers.facebook.com',
}, function(response){
if(response && !response.error_code) {
console.log(response); // => []
} else {
alert('err');
}
});
});
After content is successfully shared, the response I get is an empty array with no data. How can I get the post-id of share post?
Check out the docs for information about the response:
Only available if the user is logged into your app using Facebook and has granted publish_actions. If present, this is the ID of the published Open Graph story.
Meaning, you will only get the post-/object-id if the user is authorized with the publish_actions permission.

Fb.ui description missing on wall that has timeline enabled

I have this Facebook app where a user has to share an image. With that image they have to share I filled in a description that will show up next to the image on the users wall.
But I just found that the description is missing on pages that have the new timeline enabled. The full description does however show up in the preview screen of what they will post to their wall.
This is the fb.ui code. It does post the image itself, but the description is missing on walls that have the new timeline enabled, it works fine on none timeline enabled walls.
Any ideas on how to fix it, and make the description show up there as well? Or is it normal behavior for timeline walls to not show the description?
FB.ui(
{
method: 'feed',
name: 'Test',
link: 'https://www.facebook.com/test',
picture: 'test',
caption: 'test',
description: 'test'
},
function(response) {
if (response && response.post_id) {
alert('Okay');
} else {
alert('Fail');
}
}
);

Redirect to page with add page tab dialog

Facebook recently notified they are deprecating support for app profile pages.
Apps created after Dec 10th no longer have the app page option, together with the
"add to my page" functionality, and must use the new Add page tab dialog.
After the user selects which page to add the application to, is there any way to
redirect the user to the selected page?
Similar functionality existed in the "old" add to page dialog, e.g.
https://www.facebook.com/add.php?api_key=MY_ADD_ID&pages=1
Activating the dialog with a response function seems to bring no result.
`
// Add app to page
function addToPage() {
// calling the API ...
FB.ui({
method: 'pagetab',
redirect_uri: 'MY_URL',
},function(response) {
alert(response);
});
}
`
So, two questions:
a) Is there any possibility for the app using the dialog to "know" which page was selected?
b) Is there any way to redirect the user to the selected page.
Thx!
<script type="text/javascript">
function addToPage() {
// calling the API ...
FB.ui(
{
method: 'pagetab'
},
function(response) {
if (response != null && response.tabs_added != null) {
$.each(response.tabs_added, function(pageid) {
alert(pageid);
});
}
}
);
}
</script>
Use above code...you will get page id of pages selected by the user
but what if the user has a custom name for its page.
i modify devson.. code a bit
FB.ui(
{
method: 'pagetab',
redirect_uri: '',
},
function(response) {
if (response != null && response.tabs_added != null) {
$.each(response.tabs_added, function(pageid) {
FB.api(pageid, function(response) {
alert('redirect to ' + response.link);
});
});
}
}
);
This used to be simple, using the facebook UI.("Add to My Page") Unfortunately facebook removed this.
You can add it using www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&next=YOUR_URL
I put this an html and publisched it below. Just visit, enter your app params, hit submit, and our done.
http://www.jibecompany.com/2012/add-a-facebook-page-tab-application-to-your-page

Facebook Request 2.0

I am kind of confused on how to use the new facebook request dialog box. Using the below mentioned function opens a box and I am able to send the request to the user who receives it. But when the user clicks on the request nothing happens instead the user is redirected to an internal link:
http://www.facebook.com/?request_ids=105890902828361%2C105893002828151%2C105899456160839%2C105902046160580%2C105904092827042&notif_t=app_request
How to resolve the issue? (Canvas Page not defined in Settings but Canvas Url is)
function requestsDialog()
{
FB.ui({
method: 'apprequests',
message: 'Here is a new Requests dialog...',
title: 'example',
data: 'trackinginfo'
},
function(response) {
if (response) {
alert('Request was sent.');
} else {
alert('Request was not sent.');
}
}
);
};
You need to specify a Canvas Page. For example, if your canvas page is:
http://apps.facebook.com/test_application
Then the URL that user will go to when clicking on the request will be:
http://apps.facebook.com/test_application?request_ids=12020393994,129193929392
At which point you can use the Graph API to look up what the requests are using the id (documentation here)