Post a comment on a page/link true FB.api - facebook

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

Related

facebook feed response null

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

Facebook request permission

I have 2 questions
Does the requestPermissions field go here(Running on click)
Meteor.loginWithFacebook({requestPermissions: ['user_friends']});
or here
ServiceConfiguration.configurations.insert({
service: "facebook",
appId: Meteor.settings.facebook.appId,
secret: Meteor.settings.facebook.secret,
requestPermissions: ['user_friends']
});
When adding the requestPermissions field to the ServiceConfiguration, it does not seem to take any effect.
Both options don't show the friendslist on the services.facebook field. where can i find the friends list? Is this a bug with the current facebook accounts package? I also tried doing this
Accounts.onCreateUser(function (options, user) {
debugger;
// nothing here, options just holds name.
return user;
});
Help please
Check: http://docs.meteor.com/#/full/accounts_ui_config and also https://developers.facebook.com/docs/reference/fql/permissions/
You need ask Facebook for the permissions, there's a review process for this. It's useless to request a permission that Facebook didn't provided you. Read this topic about recent facebook changes to the API: Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app
I'm using the fbgraphpackage to query Facebook: https://github.com/criso/fbgraph

Facebook API Error 100 'link' is invalid

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?

Check if user can write on a friend's Wall

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.

Tagging friends in a fb.api status update?

Is it possible to tag friends somehow using the Facebook fb.api (JavaScript SDK) call?
By tagging I mean what happens when you use "#" in the regular facebook.com UI.
It is currently not possible to tag a friend in a status update or post via the API.
Not sure if that's what you are asking, but the syntax to tag a friend using Facebook API is #[uid:friend name]. However, it seems like there is a bug at the moment and FB does not support it.
Check the Facebook documentation for more information about this: photos.addTag.
Quote:
Each tag in the list must specify: "x", "y", and either the user id "tag_uid" or free-form "tag_text" identifying the person being tagged. An example of this is the string {"x":"70.0","y":"70.0","tag_text":"some person"}
And read in FB.api on how to use the REST API calls using JavaScript.
Yes, you can use FB.api to tag a friends.
E.g. If you would like to a tag a friend(s) withing a message that you will share on a Fb's wall you have to do following.
1) Get extended permissions ('publish_stream') e.g. you can request it while login to the app FBUser.login({scope: 'publish_stream'});
2) You have to pass a string with the facebook_user_id to a 'tag' key of the api object. e.g.
FB.api('me/feed', 'post', {
message: "my message here",
place: '123456789', // mandatory!!!
tags: "123456, 654321, 147258, 852963", // facebook users ids of your friends
name : "Some text here",
description : "Some text here",
picture: "http://wwww.link.to/the_image"})