-
-
Notifications
You must be signed in to change notification settings - Fork 191
Posts and Comments
nov edited this page Jun 18, 2013
·
2 revisions
# single post
FbGraph::Post.fetch(POST_ID, :access_token => ACCESS_TOKEN)
# posts by me
FbGraph::User.me(ACCESS_TOKEN).posts
# posts by a page
FbGraph::Page.new(PAGE_ID, :access_token => ACCESS_TOKEN).posts
When generating a new post, use `feed` connection, instead of `posts`.
# post as an user
FbGraph::User.me(ACCESS_TOKEN).feed!(
:message => 'hello world'
)
# post as a page
FbGraph::Page.new(PAGE_ID, :access_token => ACCESS_TOKEN).feed!(
:message => 'hello world'
)
FbGraph::Post.new(POST_ID, :access_token => ACCESS_TOKEN).destroy
# post comments
FbGraph::Post.new(POST_ID, :access_token => ACCESS_TOKEN).comments
# comment replies (comment replies are also comment objects)
FbGraph::Comment.new(COMMENT_ID, :access_token => ACCESS_TOKEN).comments
# fetch "can_comment" property, specify "fields" option
comment = FbGraph::Comment.fetch(COMMENT_ID, :access_token => ACCESS_TOKEN, :fields => "can_comment")
comment.can_comment
# post a comment on a post
post = FbGraph::Post.new(POST_ID, :access_token => ACCESS_TOKEN)
post.comment!(
:message => 'hello'
)
# reply to a comment
comment = FbGraph::Comment.fetch(COMMENT_ID, :access_token => ACCESS_TOKEN, :fields => "can_comment")
if comment.commentable?
comment.reply!(
:message => "Hello!",
:access_token => ACCESS_TOKEN
)
end
FbGraph::Comment.new(COMMENT_ID, :access_token => ACCESS_TOKEN).destroy