简体   繁体   English

从chrome扩展名分享到Facebook

[英]share on facebook from chrome extension

I want to share current opened tab url on facebook wall from chrome extension. 我想从Chrome扩展程序共享Facebook墙上当前打开的标签页网址。 For that, I was using https://facebook.com/share.php earlier which was giving me login option first and then share box. 为此,我之前使用的是https://facebook.com/share.php ,它首先给了我登录选项,然后提供了共享框。

Since facebook has deprecated this method, how can I post/share on my wall from chrome extension? 由于facebook已弃用此方法,如何通过chrome扩展程序在墙上发布/共享? FB.api is another option but for that I may have to authenticate with facebook first. FB.api是另一种选择,但为此,我可能必须先通过Facebook进行身份验证。 How can I achieve this from chrome extension? 如何从Chrome扩展程序中实现这一目标?

You can use feed dialog, find more detail here 您可以使用Feed对话框, 在此处找到更多详细信息

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/

Accepted answer doesn't work for me. 接受的答案对我不起作用。

Found another way to share on facebook ( jsfiddle ): 找到了另一种在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 : //apps.lazza.dk/facebook/ (© Facebook sharer.php是否已更改为不再接受详细参数? ),这是一个反向工程示例:

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: 对于更大的图片,我们应该省略报价:

大图分享

Here's another method: Create a bookmark and set name to "Share on Facebook" and the URL to: 这是另一种方法:创建一个书签,并将名称设置为“在Facebook上共享”,并将URL设置为:

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. 注意:我没有发明这种方法,也不记得从何处获得这种方法,但是它对于Chrome和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 : //www.facebook.com/share_options.php在此页面上,只需将“在Facebook上共享”图标拖到书签栏即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM