views:

467

answers:

5

I have some code like the following in my application:

message = "Hi, @John Doe!"
postID = fb.stream.publish(
    message = loader.render_to_string('wall_post.phtml', {'message':message}),
    action_links = simplejson.dumps([{'text': "Check out blah", 'href': "http://blah.dev"}]),
    target_id = 'nf'
)

Is there any way to represent a facebook @mention in the message string so that facebook converts it to a profile link for the mentioned user?

+3  A: 

I've also been looking for an answer to this. The facebook website uses the format:

@[139730900025:PhotoGrabber] is awesome

to represent the links but I haven't been able to make that work. I re-posted a thread on the facebook forum under the "Stream" category since your post wasn't getting any attention:

http://forum.developers.facebook.com/viewtopic.php?id=47885

tam7t
Hey. Just saw your response here and your message in the facebook forum saying that you gave up. Just a heads up, but I eventually did the same. I was trying to make the facebook side of http://atlibs.matchstrike.net as @mention friendly as the Twitter side, but things picked up and we're working on other things now. Thanks for trying though, I appreciate it.
Thomas
Has anyone found out how to do this?
Jayrox
A: 

I'm pretty sure this is impossible at the moment. If it were posible by using the format that tam7t suggested it should work... Your best bet is asking them to add that to their api stream parser.

Chad Scira
A: 

This is not possible at the moment, sorry.

marcgg
A: 

This actually is a real feature, Critter Island uses it actively alongside their gifting feature. Any ideas??

Colin Godsey
Critter Island has been pinged recently for using an exploit hack to get this to work.
zizee
A: 

I'm thinking the best approach at the moment would be to write a screen scraper to do these posts using the format described by tam7t's answer. If you use the mobile version of facebook's site (m.facebook.com) it makes it much easier.

The only thing I don't know at the moment is if this is a violation of Facebook's Application TOS.

Edit: Here is some ruby code that will do the trick, using the Mechanize Gem

require 'mechanize'

agent = Mechanize.new
agent.user_agent_alias = 'Mac Safari'

page = agent.get('http://m.facebook.com')
form = page.forms.first
# enter credentials
form.pass = 'user password'
form.email = '[email protected]'
page = agent.submit form

# go straight to page to post on 
page = agent.get("http://m.facebook.com/wall.php?id=PAGE_ID_NUM")
form = page.forms.first
form.message = "@[139730900025:PhotoGrabber] is awesome"
page = agent.submit form

That said, back to the original question of putting an @mention in a wall post, I have noticed that whilst the post and @mention go up on the wall fine, this method does not propagate the post to the mentioned user/page's wall. Not sure if that is important to you.

zizee

related questions