i am using below code to share fb feed
FB.ui({
method: 'feed',
link: 'https://developers.facebook.com/docs/',
caption: 'An example caption',
}, function(response){ console.log(response); });
response is always null i could not figure out why , i think when share done it must output some response
ref link : https://developers.facebook.com/docs/sharing/reference/feed-dialog/v2.5
Please guide if i am missing something
There is only a reliable callback if you authorized the user with the publish_actions permission. In that case, you will get the Post ID in the callback.
Else, there is no way to determine if a user shared something.
Keep in mind that you are not allowed to reward users in any way for sharing according to the platform policy: How to upload multiple images to one post in facebook via api
Related
how can post on my facebook friends wall using FB.UI
my code is
FB.ui({
method: 'feed',
link: 'https://developers.facebook.com/docs/',
to:['405631902932995,626150064162274'],
caption: 'An example caption'
}, function (response) {
console.log(response);
});
i am getting error like
API Error Code: 100
API Error Description: Invalid parameter
Error Message: ["100004585663846,100003018593104"] does not resolve to a valid user ID
That parameter only allows to enter one ID, not an array of them. Meaning, what you want to achieve is not possible at all, you can only specify one friend.
https://developers.facebook.com/docs/sharing/reference/feed-dialog/
You can also use the Send Dialog to send a message to a friend: https://developers.facebook.com/docs/sharing/reference/send-dialog
The same applies to the "to" parameter, you can only specify one recipient.
I am following this thread Is it possible to add a link to download a file that can only be downloaded by sharing it on Facebook? to detect if user share my given link or not, If user share then allow him to access the next level.
This is how i am doing:
FB.ui({
display: 'popup',
method: 'share',
href: 'url-here',
} , function(response){
console.log(response.e2e)
if (response && response) {
$.ajax({
url: ajaxurl,
type: 'post',
data: {action: 'unlock_om_gmap'},
success: function(res) {
}
});
}
});
But everytime its returning Object { e2e="{"submit_0":1406412308276}"} not any post id. Is there anyone familiar with this issue? How do i check if user shared my link or not?
As I mentioned in the comments, as per the Facebook docs on this topic, you'll need to check for an object_id property in the response data to determine if an Open Graph story was shared, but this is only available if the user is logged into your app using Facebook and has granted publish_actions
I have my site qa.carryon.com (this is our test site). I have configured it for facebook login and send invitations. In facebook I have configured SiteURL as 'http://login.qa.carryon.com/gs/'. 'login.qa.carryon.com' is our CNAME and we are using Gigya as social third party.
Login is working fine and when users see the list of facebook friends, user will click on one of them and the facebook send dialog triggers. The link parameter for send dialog is something like this 'http://qa.carryon.com/loyalty/signup?userid=xghdt6ys&username=xyz'.
For this link am i getting the error code 100 link invalid or there is other issue in configuration. I am doing this for first time and i cant understand whats going on. Please help i am stuck with no clue.
I had this issue as well and I was using dynamic querystring parameters on a common URL. It seems you are doing the same.
I fixed the issue by forcing Facebook to scrape the URL before I attempt to send it via the FB UI Send Dialog. Use the FB API to hit graph.facebook.com with the URL posted in the id parameter and a scrape parameter set to true.
Like so:
FB.api('https://graph.facebook.com/', 'post', {
id: '[URL]',
scrape: true
}, function(response) {
FB.ui({
method: 'send',
name: '[name]',
picture: '[Picture URL]',
link: '[URL]',
description: '[description]'
});
});
Also answered here.
Does that help?
Is there a method for posting comments on pages with Facebooks js api? FB.api().
You can post on a persons wall with
FB.api('/me/feed', 'post', { caption: message, name: "the tile", description: "a neat message", link : "http://www.stackoverflow.com" }, function(response) {});
But is there an equivalent of posting a comment to a page? Without the social-plugin "comments box". Anyone?
All of the graph api is built on urls, all of the different SDKs (including the js one) just wrap up the http requests for you.
As the documentation for page states:
feed
This connection corresponds to the Page's Wall. You can create a link,
post or status message by issuing an HTTP POST request to the
PAGE_ID/feed connection. To see more details please see links, posts,
and status messages documentation.
To impersonate the Page when posting to the wall (i.e. post as the
Page, and not the current user), you must use a Page access_token with
the manage_pages and publish_stream permissions, as described under
Page Access Tokens above.
To do that from the javascript sdk then is something like this:
FB.api('/PAGE_ID/feed', 'post', { caption: message, name: "the tile", description: "a neat message", link : "http://www.stackoverflow.com" }, function(response) {});
yes you can, but you must be administrator of the page and you must request the access token with the correct authorization: publish_stream, offline_access, manage_pages, read_stream
there is a great tutorial here to get your access_token and to post message: http://sp4ce.net/computer/2012/02/15/facebook-page%3A-automatic-answer.html
Here is official Facebook page for that:
http://developers.facebook.com/docs/reference/api/page/
Seems that it is not possible, and will never be:
This functionality was never and is not intended to be available.
An error message has been added for this case: "Comments may not be
added to a comment plugin"
https://developers.facebook.com/bugs/164794086987157
If there any way to check in PHP SDK if user can write on specific friend's Wall?
Example:
if ($facebook_can_write_to->'123456789') echo "You can write on this friend's Wall";
Using the FQL table (http://developers.facebook.com/docs/reference/fql/user/) you can check to see if the current user can post to a friends wall by loading up the friend's user information specifically the can_post field.
can_post bool Whether or not the viewer can post to the user's Wall.
According to the documentation you can post on a user friends wall if that user granted you the *publish_stream* permission:
publish_stream
Enables your app to post content, comments, and likes to a user's
stream and to the streams of the user's friends.
There are some cases in which you won't be able to do so, for example if some user blocked your application then I guess it will fail if you try, so you should just check the response you get back from facebook for the api request and see if it worked or not.
Edit
As far as I'm aware you can not ask the api (nor via fql) "can my application post to this users wall", you can only ask "have this user granted my application the publish_stream permission".
If I understand what you want, I might have kind of a solution for you though.
I say show the user the option to post on a friends wall.
When the user chooses this option try to post on the friends wall (and I assume you are using ajax for that call), if it fails return some kind of code, then in the client side check for that code, if it returns use the javascript sdk to open a dialog.
You have two choices for dialogs, you can use the Feed Dialog like this:
var obj = {
method: 'feed',
to: "FRIEND_ID",
name: 'A message',
caption: 'Just trying something',
description: 'This is how to post on a friends wall'
};
FB.ui(obj, function(response) { console.log(response); });
Or you can use the Send Dialog:
FB.ui({
method: 'send',
to: "FRIEND_ID",
name: 'A message',
link: 'LINK_URL',
});
With this one though you have to post a link, I'm not sure if that works for you. After you tried and failed for a user you can save that data and use it later.