Michał Kwiatkowski
Michał Kwiatkowski

Reputation: 9764

How to embed a link in a Facebook post through the Graph API

I want to post in behalf of the user a message that contains a link to another Facebook page. Something that is easily achievable through Facebook interface by choosing an autocompleted name of the page:

example of the embedded link

I use Ruby with the koala gem. I tried to do something like this:

graph = Koala::Facebook::API.new(access_token)
graph.put_object(page_id, "feed", message: "Embedded @[23497828950:National Geographic] link")

but it doesn't convert the link. I could post a full URL but that doesn't look as nice.

Is there a way to achieve the same thing as on Facebook (a linked page title) through the Graph API?

Upvotes: 0

Views: 582

Answers (1)

Sahil Mittal
Sahil Mittal

Reputation: 20753

This can only be accomplished using the Open Graph Actions.

POST /me/cookbook:eat?
     recipe=http://www.example.com/recipes/pizza/&
     message=You should really try this recipe from @[115401158528672]&
     access_token=VALID_ACCESS_TOKEN

If you are not aware of Open Graph API, you can start from here: https://developers.facebook.com/docs/opengraph/

Just follow the steps mentioned in the tutorial, quite easy to integrate and make your stories more beautiful.

Upvotes: 1

Related Questions