0

I am using Koala gem and in my UI i have an share link. How can i share the posts using the post id. Can it be done like this.

@facebook = FacebookToken.first
@graph = Koala::Facebook::API.new(@facebook.access_token)
@graph.put_object(params[:post_id], "share",:message => "First!")

It gives the following error

 Koala::Facebook::ClientError: type: OAuthException, code: 240, message: (#240) Requires a valid user is specified (either via the session or via the API parameter for specifying the user. [HTTP 403]

I thing something going wrong with permission. I have added the following permission in the fave bool app

"share_item,manage_pages,publish_stream,read_stream,offline_access,create_event,read_insights, manage_notifications"

Do I need to some other permission to share a post using post id

user1683039
  • 75
  • 1
  • 8

1 Answers1

0

The first parameter in put_object is not the post ID, but the ID of who is sharing it, be it a page or user.

So instead of saying:

@graph.put_object(params[:post_id] ...

You would say:

//the current user
@graph.put_object('me' ...

or

//any user that you have a UID for
@graph.put_object(@user.uid ...

or

//a page that you have post permissions for
@graph.put_object(@facebook_page.id ...

Also in a future version of Koala, put_object will be a bit different, and you should go ahead and switch over to put_connection.

zkwentz
  • 1,095
  • 5
  • 22
  • 44