Facebook Connectを統合するfacebooker2を使用している場合は、おそらくクライアント側で行う必要があります。私が正しく理解していれば、facebooker2はサーバー側のAPIを提供していません。
したがって、JavaScript SDKをロードし(接続に成功した場合はロードする必要があります)、統合されたFacebookUIを使用してステータスを投稿します。
FB.ui({
method: 'stream.publish',
attachment: {
name: 'JSSDK',
caption: 'The Facebook JavaScript SDK',
description: (
'A small JavaScript library that allows you to harness ' +
'the power of Facebook, bringing the user\'s identity, ' +
'social graph and distribution power to your site.'
)
}
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
FB.ui
次のダイアログをサポートします。
- friends.add
- stream.publish
- stream.share
- fbm.dialog
- ブックマーク.add
- profile.addtab
派手なUIを使用せずに、ステータスの更新をフィードに直接公開したくない場合は、次のFB.api
関数を使用します。
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);
}
});
アップデート:
実際には、このすべてのサーバー側を実行できます-最初はMongliに気づいていませんでした-FB Open Graph API(facebooker2 gemはそれに依存します)、サンプルコントローラーアクションを統合します:
def create
note = current_user.sent_notes.create!(params[:note])
flash[:notice] = "Note sent to #{note.recipient.email}"
if current_facebook_user
current_facebook_user.fetch
current_facebook_user.feed_create(
Mogli::Post.new(:name => "#{current_facebook_user.name} sent a note using notes!",
:link=>note_url(note),
:description=>truncate(note.body,:length=>100)))
end
redirect_to notes_path
end
@https ://github.com/mmangino/mogliでMogliを参照してください
@https://github.com/mmangino/facebooker2_fb_connect_exampleでfacebooker2の例を参照してください