Facebook share callback, more data? - facebook

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

Related

facebook connect Phonegap api

I'm having a issue with accessing the Facebook connect Graph API, I have used this plugin, the login example works great and share example also works fine.
I have a problem getting a response from the Facebook API to work.
$(document).ready(function() {
$("#fb_info").click(function() {
facebookConnectPlugin.api("/me",
function (response) {
if (response && !response.error) {
alert(response);
}
}
);
});
});

What is the error in the following code

Here is a function which is call when user click a button to attend a event on facebook, these following code get the login information from user and add there particular event to the user fb event to attending the event.
These code is giving me the syntax error, i does not Know what is the error. Please help its needy.
function gogingtoevent() {
FB.login(function(response) {
if (response.status == 'connected') {
FB.api('/816891388384961/attending',
function (response) {
if (response && !response.error) {
alert('Attending');
}else{
alert (JSON.stringify(response));
}
});
}else{
alert('Not Responding');
}
});
}
You need to do a POST request to this edge, and you need the rsvp_event permission.
It's all in the docs:
https://developers.facebook.com/docs/graph-api/reference/v2.3/event/attending#publish
https://developers.facebook.com/docs/facebook-login/permissions/v2.3#adding

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.

Facebook app: change post-on-wall privacy

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.

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