简体   繁体   English

使用不带fb:login-button的FB.Connect.showFeedDialog进行Facebook连接

[英]facebook connect using FB.Connect.showFeedDialog without fb:login-button

I have a facebook application set as a iframe and i'm trying to use FB.Connect.showFeedDialog to publish stories to a users feed. 我将一个Facebook应用程序设置为iframe,并且我试图使用FB.Connect.showFeedDialog将故事发布到用户供稿。 I'm working from this example http://papermashup.com/using-facebook-connect/ which doesn't work until you login using the fb:login-button. 我正在使用此示例http://papermashup.com/using-facebook-connect/进行操作,直到您使用fb:login-button登录后,该示例才起作用。

I've been attempting to modify the code for several days and I was wondering if it's even possible to do without this login button if its a Facebook Iframe applicaiton. 我一直在尝试修改代码几天,我想知道如果没有它的Facebook Iframe应用程序,即使没有此登录按钮也可以这样做。

Any help and pointers much appreciated. 任何帮助和指针,不胜感激。

It's definitely possible without a fb:login-button . 没有fb:login-button绝对有可能。 In fact, if you're building an iframe app, then you probably don't need an fb:login-button at all. 实际上,如果您要构建iframe应用,则可能根本不需要fb:login-button All you need is to load the Facebook Connect libraries , and then make the initialize call , like this (using your own API key of course): 您所需要做的就是加载Facebook Connect库 ,然后进行初始化调用 ,就像这样(当然使用您自己的API密钥):

<script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">
    FB.init("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "/xd_receiver.htm");
    window.addEvent('domready',function(){
        FB_RequireFeatures(["CanvasUtil"], function(){
            FB.XdComm.Server.init("/xd_receiver.htm");
        });
    });
</script>

Note that I've got a bit of MooTools in there to make sure the RequireFeatures call happens after the DOM is ready. 请注意,我那里有一些MooTools,以确保在DOM准备好后进行RequireFeatures调用。 You can stick to the examples in the initializing docs if you want. 如果需要,可以坚持使用初始化文档中的示例。

Anyway, once you've loaded and initialized the FB Connect libraries, you should have full access to the API methods that the JS library provides, and you can simply do this: 无论如何,一旦加载并初始化了FB Connect库,您就应该具有对JS库提供的API方法的完全访问权限,只需执行以下操作:

var user_message_prompt = "Write something here!";
var user_message = {value: "Default message"};
if (FB.Connect) {
    FB.Connect.showFeedDialog(templateBundle, templateData, null,null,null,FB.RequireConnect.require,null,user_message_prompt,user_message);
}

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

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