Post to User Wall using offline_access in facebook Javascript Sdk - facebook

My problem is that i want to post to user wall using the offline_access.
I donot know how to do that using the facebook javascript sdk
with this method FB.api('/me/feed')
Please also give me an example how to integrate the facebook connect with asp

If the user has already authenticated and has given publish_stream or offline_access permissions, you can just call this method to publish to their feed:
var body = 'Reading Connect JS documentation';
FB.api('/me/feed', 'post', { message: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});

Related

Facebook Post through Graph API with access token

I am developing a facebook app where I need impersonation of users, so there is an option when you use facebook for "Use Facebook As", i need to implement the same in my app.
I see the access tokens retrieved for the pages I own, but I don't understand how to use this with the following graph api to post
var body = 'Reading JS SDK documentation';
FB.api('/me/feed', 'post', { message: body }, function (response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
so my question is how do I set the access token for the api in this case??
I Hope, am clear with my question
Add it with the parameters. Change this line
FB.api('/me/feed', 'post', { message: body }, function (response) {
to...
var my_token = "the access token value";
FB.api('/me/feed', 'post', { message: body, access_token : my_token }, function (response) {

Posting to a user's wall in FB with permission, possible?

is it possible to login to a website with a FB login and have the user post to his friend with permission? By "with permission" I mean the friend has to approve the post. Is this possible?
Yes it is possible. We have an application at my job that posts on the user's profile, as them, every week.
From the facebook doc (https://developers.facebook.com/docs/reference/javascript/FB.api/):
If you have an authenticated user with the publish_stream permission, and want to publish a story to their feed:
var body = 'Reading JS SDK documentation';
FB.api('/me/feed', 'post', { message: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});

posts_id of POSTS using GRAPH API

I am posting posts on Users wall using Graph API.
How can I get the Post ID for these posts which I am doing so i can later
read or write comments on these posts?
FB.api('/me/feed', 'post', { link: body,picture:PICTURE,name:'NAME',description:'DESCRIPTION',caption:'CAPTION',message:'MESSAGE' }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id); //response.id is the post ID of the post published.
}
Sorry you are using graph api...My bad.
When the post is published you get the id in the response.
Check it. it should be in JSON fomat. "id:POST_ID" Something like that.

Facebook Javascript SDK: Tag another user in my wall post?

We are using the Facebook Javascript SDK to allow users to post content to their wall. In the message that gets posted, is it possible to tag another user, similar to how you can when typing a post on facebook.com? (using something like #person)
We are using:
FB.api('/me/feed', 'post', { message: 'This post came from a test. #someuser'}, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
The end result would then be a post that tagged the #someuser user.
The Facebook API doesn't currently support tagging of users like this. That functionality is limited to the actual site itself.

Is an onject id returned when publishing via Facebook GraphAPI?

I am planning an app that will post to a users FB wall. When posting via the GraphAPI is an object id returned for the new post? We want to use the post id later to retrieve data about the post.
If you look at FB.ui() example for stream.publish, post_id is returned with the response.
Looking at this example from their FB.api docs, it certainly seems possible.
var body = 'Reading Connect JS documentation';
FB.api('/me/feed', 'post', { body: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response);
}
});