views:

31

answers:

1

Hi,

im trying to automatically publish a post on the logged in users wall in facebook in my canvas (iframe) application. the only way to do this, is by using oauth via php i think? i see no way to do this automatically via the new js-sdk.

so before i publish this post, i want to check, if i have already posted this content on his/her wall. is there a method or a way to check this? or do i have to store this in my own DB with the users id?

thanks for your help. if anything is unclear , PLEASE leave a comment.

A: 

https://graph.facebook.com/me/feed will get the the logged in user's feed so you can check if the one you are looking for is already posted. With the Javascript SDK you can simply do:

var feed = FB.api('/me/feed');
//Loop through the feed for the post

You can actually post with the Javascript SDK instead of php if you want. Assuming the user is logged in and you have publish stream permissions from the user, you would just do:

FB.api('/me/feed', 'POST', {message: 'This is the message'}, function(response) {
    //This is the callback function
    //The response variable will tell you if you successfully posted
});
jcmoney
this will not promt a popup with "really post xyz" ? yes, the users have granted publish.stream perms at this moment
choise
Right this will just publish without prompting since you have stream publish permission. if you want to ask them then use FB.ui: http://developers.facebook.com/docs/reference/javascript/FB.ui. I believe you do not need stream publish in this case.
jcmoney
ill give it a try, thanks!
choise