Is there a way to insert an @mention into a Facebook status update posted with pyfacebook?

后端 未结 5 1234
你的背包
你的背包 2021-01-03 08:50

I have some code like the following in my application:

message = \"Hi, @John Doe!\"
postID = fb.stream.publish(
    message = loader.render_to_string(\'wall_         


        
相关标签:
5条回答
  • 2021-01-03 09:38

    This is not possible at the moment, sorry.

    0 讨论(0)
  • 2021-01-03 09:39

    AFAIK facebook's API does not allow this. The only approach that I know of 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.

    NOTE: This might be 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 = 'user@example.com'
    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
    

    NOTE: Obviously (as tiagoboldt kindly pointed out) it would be wrong to store / utilise the credentials of other people in your application. This approach would only be appropriate for making posts from a facebook account that you controlled.

    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.

    0 讨论(0)
  • 2021-01-03 09:44

    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.

    0 讨论(0)
  • 2021-01-03 09:46

    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

    0 讨论(0)
  • 2021-01-03 09:48

    Mention it's partially available by open graph now. You can use only when posting an open graph ACTION

    Check: https://developers.facebook.com/docs/opengraph/mention_tagging/

    It seems still impossible to use @mention tagging in classic feed posting via API

    0 讨论(0)
提交回复
热议问题