share on facebook from chrome extension

微笑、不失礼 提交于 2019-12-19 10:29:17

问题


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 first and then share box.

Since facebook has deprecated this method, how can I post/share on my wall from chrome extension? FB.api is another option but for that I may have to authenticate with facebook first. How can I achieve this from chrome extension?


回答1:


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/



回答2:


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:




回答3:


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.



来源:https://stackoverflow.com/questions/14283842/share-on-facebook-from-chrome-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!