简体   繁体   English

使用来自Javascript变量的消息更新Facebook状态

[英]Updating facebook status with message from a Javascript variable

Is there an easy way to let users update their status on Facebook with a message I have in a JavaScript variable? 是否有一种简单的方法可以让用户使用JavaScript变量中的消息在Facebook上更新其状态? I know there's a URL you can use to share a link, which looks like: 我知道有一个可用于共享链接的URL,如下所示:

<a href="http://www.facebook.com/sharer.php?u=www.fthisclass.com/jshoregen.html&t=title">testlink </a>

That doesn't fill in a status update when it takes them to the share page. 当它们进入共享页面时,它不会填写状态更新。 Is there a way I can have that pre-filled, or have their status automatically updated? 有没有一种方法可以预先填充,或者自动更新状态?

Thanks! 谢谢!

Edit: Not quite what I'm going for. 编辑:不是我想要的。 I can use PHP if necessary (although I have very little experience with it), but I don't want to have to bug users with allowing an application, or have to deal with actually writing a facebook app. 我可以在必要时使用PHP(尽管我对它的经验很少),但我不想让用户在允许应用程序时遇到错误,或者必须处理实际编写的Facebook应用程序。 I just want to give users a premade status update, so all they have to do is click the 'share' button. 我只想给用户一个预制状态更新,所以他们所要做的就是点击“分享”按钮。 Thanks again! 再次感谢!

Edit 2: So the api looks promising, but a little complicated for me. 编辑2:所以api看起来很有希望,但对我来说有点复杂。 It looks like it would involve getting permission from the user to set their status, and possibly something about setting up a cross-communications channel to let my site communicate with facebooks. 看起来它将涉及获得用户的许可以设置其状态,并且可能涉及设置跨通信渠道以使我的站点与facebook通信。 Assuming I can do that, how do I go about using the Facebook Javascript api? 假设我能做到这一点,我该如何使用Facebook Javascript api? I get the code (user_setStatus looks easy enough), but how do I tell my script that I'm using Facebook's api? 我得到了代码(user_setStatus看起来很简单),但是如何告诉我的脚本我正在使用Facebook的api? Thanks again...again! 再次感谢...再次!

Try this: 尝试这个:

http://www.facebook.com/connect/prompt_feed.php?&message=my%20awesome%20status http://www.facebook.com/connect/prompt_feed.php?&message=my%20awesome%20status

[EDIT] Link is not working please update it. [编辑]链接不起作用请更新它。

Is the facebook javascript API not what you're looking for? facebook javascript API不是您想要的吗? It seems to expose the entire REST-ful API as a javascript library. 它似乎将整个REST-ful API公开为javascript库。

users_setStatus(...) looks promising. users_setStatus(...)看起来很有前途。

Here is working example which requires application ID, but fully working and it is easy to implement: 这是一个需要应用程序ID的工作示例,但是完全正常工作并且易于实现:

<a href="http://www.facebook.com/dialog/feed?app_id=123050457758183&link=http://www.build.server.com&picture=http://fbrell.com/f8.jpg&
  name=Some%20Encoded&Message=Reference%20Documentation&
  description=Using%20Dialogs%20to%20interact%20with%20users.&
  redirect_uri=https://arapskirjecnik.web44.net/"> Share with FB</a>

see more here 在这里看到更多

here is the way which works and it doesn't requires facebook application id: 这是工作的方式,它不需要Facebook应用程序ID:

<a onClick="window.open('http://www.facebook.com/sharer.php?s=100&amp;p[title]=Title&amp;p[summary]=summary&amp;p[url]=www.build.server.com&amp;p[images][0]=http://fbrell.com/f8.jpg','sharer','toolbar=0,status=0,width=548,height=325');" href="javascript: void(0)">Insert text or an image here.</a>

As you can see from above code you can enter custom title, summary, link and images. 从上面的代码中可以看出,您可以输入自定义标题,摘要,链接和图像。

and if you want to automate, to share current link, youst replace this part of the code in upper example: 如果你想自动化,共享当前的链接,你在上面的例子中替换这部分代码:

p[url]='+ document.URL +'&amp;p[images]

Not sure if you're using PHP but here's a link that shows you how to use the Facebook API to update the status. 不确定您是否使用PHP,但这里有一个链接,向您展示如何使用Facebook API更新状态。 You could call a page with Ajax from Javascript, passing in the variable and have that posted to the Facebook status message. 您可以使用Javascript从Ajax调用页面,传入变量并将其发布到Facebook状态消息。

http://fbcookbook.ofhas.in/2009/02/07/facebook-reveals-status-api-how-to-use-it/ http://fbcookbook.ofhas.in/2009/02/07/facebook-reveals-status-api-how-to-use-it/

Using just mcqwerty solution you'll get an annoying resize screen effect. 使用mcqwerty解决方案,您将获得恼人的调整大小屏幕效果。

But, you can add a parameter in order to avoid this flickering. 但是,您可以添加参数以避免这种闪烁。 Display touch will avoid this. 显示触摸将避免这种情况。

https://www.facebook.com/connect/prompt_feed.php?display=touch&message=Hiall https://www.facebook.com/connect/prompt_feed.php?display=touch&message=Hiall

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

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