简体   繁体   English

如何使用JavaScript在Facebook上共享文本?

[英]how to share text on facebook using javascript?

I am developing an android application using PhoneGap. 我正在使用PhoneGap开发一个android应用程序。 I need to post text on Facebook. 我需要在Facebook上发布文字。 I know that in Twitter it can be done through below code . 我知道在Twitter中可以通过以下代码完成。

var mediaSource = "http://twitter.com/home?status={TITLE}";
mediaSource = mediaSource.replace('{TITLE}',"Text to be share in Twitter");

window.location = mediaSource;

Is there any similar method to post text in Facebook? 有没有类似的方法可以在Facebook中发布文字?

Edit : I got a partial solution from this egrappler 编辑:我从这个egrappler得到了部分解决方案

my code as follows : 我的代码如下:

var mediaSource = "http://www.facebook.com/share.php?u={ADDRESS}";
mediaSource=mediaSource.replace('{ADDRESS}',encodeURIComponent('http://www.google.com'));
window.location = mediaSource;

from the above code I am able to share only the link in facebook wall. 从上面的代码中,我只能在Facebook墙上共享链接。 I need to share text with the link . 我需要通过链接共享文本。 The text should be sent through the code along with the website link. 文本应通过代码以及网站链接发送。 Please help me to sort out this problem. 请帮助我解决这个问题。

Using a phonegap plugin you can post text on Facebook. 使用phonegap插件,您可以在Facebook上发布文本。 This plugin is called Share 这个插件叫做Share

Then adding .java and .js files to your project, all will be done! 然后将.java和.js文件添加到您的项目中,全部完成!

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

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