share on facebook from chrome extension

后端 未结 3 682
情话喂你
情话喂你 2021-01-15 13:22

I want to share current opened tab url on facebook wall from chrome extension. For that, I was using https://facebook.com/share.php earlier which was giving me login option

相关标签:
3条回答
  • 2021-01-15 14:00

    Accepted answer doesn't work for me.

    Found another way to share on facebook (jsfiddle):

    https://www.facebook.com/sharer/sharer.php?u={url}
    

    There is a tool that generates sharing dialog: https://apps.lazza.dk/facebook/ (© Has Facebook sharer.php changed to no longer accept detailed parameters?), here is an reverse engineered example:

    https://www.facebook.com/sharer/sharer.php
    ?u=${url}
    &picture=${pictureUrl}
    &title=${title}
    &caption=${caption}
    &quote=${quote}
    &description=${description}
    

    This link generates sharing dialog like this:

    For a bigger picture we should omit quote:

    0 讨论(0)
  • 2021-01-15 14:01

    You can use feed dialog, find more detail here

    This is a direct URL

    https://www.facebook.com/dialog/feed?
      app_id=458358780877780&
      link=https://developers.facebook.com/docs/reference/dialogs/&
      picture=http://fbrell.com/f8.jpg&
      name=Facebook%20Dialogs&
      caption=Reference%20Documentation&
      description=Using%20Dialogs%20to%20interact%20with%20users.&
      redirect_uri=https://mighty-lowlands-6381.herokuapp.com/
    
    0 讨论(0)
  • 2021-01-15 14:19

    Here's another method: Create a bookmark and set name to "Share on Facebook" and the URL to:

    javascript:var d=document,f='http://www.facebook.com/share',l=d.location,e=encodeURIComponent,p='.php?src=bm&v=4&i=1274665734&u='+e(l.href)+'&t='+e(d.title);1;try{if (!/^(.*\.)?facebook\.[^.]*$/.test(l.host))throw(0);share_internal_bookmarklet(p)}catch(z) {a=function() {if (!window.open(f+'r'+p,'sharer','toolbar=0,status=0,resizable=1,width=626,height=436'))l.href=f+p};if (/Firefox/.test(navigator.userAgent))setTimeout(a,0);else{a()}}void(0)
    

    Note: I didn't invent this method and I don't remember where I got it from, but it works great for both Chrome and Firefox. (I haven't tried it on other browsers.)

    EDIT: I found the original source: https://www.facebook.com/share_options.php On this page, just drag the "Share on Facebook" icon to your bookmarks bar.

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