English 中文(简体)
How to use Facebook FBJS Feed Forms
原标题:

I m trying to call a Feed Form in my Facebook application and I m not sure how to do so. I m not familiar with the FBJS and its API. Specifically I need the following dialogue to show up: http://wiki.developers.facebook.com/index.php/Feed_Forms

Here s what I got for now:

<script type="text/javascript">
var attachment = <?php echo json_encode($attachment); ?>;
return attachment;
Facebook.streamPublish(<?php echo $message; ?>, attachment, null, <?php echo $user; ?>);
</script>

Is there anything else I need to do in order to properly call a Feed form? A code example would help me a lot if anyone is willing to write one up.

最佳回答

For FBML canvas pages, all you need to do is execute the command as follows:

<script type="text/javascript">

var attachment = <?php echo json_encode($attachment); ?>;

Facebook.streamPublish(  , attachment, null);       

</script>

That should easily bring up the Feed Form.

问题回答

Here s an example I use from a Facebook Connect site that I operate:

var message =  This is my message! ;
var attachment = {
     name : Page name ,
     href : http://mysite.com ,
     caption : Some kind of caption ;
};
attachment.media = [{ type : image , src : http://mysite.com/images/lolcat.jpg , href : http://mysite.com }];
var action_links = [{ text : Action Link! , href : http://mysite.com }];
FB.Connect.streamPublish(message, attachment, action_links);

The FB.Connect methods are almost identical to the normal JS methods, so something similar should be working for you.

I would point out that you have <?php echo $message; ?> as the first parameter to your Facebook.streamPublish() call. Assuming $message is a text string, then you need to wrap that output in quotes in order for it to be valid Javascript. As well, the return attachment; line doesn t make much sense to me. Why is there a return statement there? I would change your code to this:

<script type="text/javascript">
var attachment = <?php echo json_encode($attachment); ?>;
Facebook.streamPublish( <?php echo addslashes($message); ?> , attachment, null, <?php echo $user; ?>);
</script>




相关问题
Facebook Connect login dialog not working

I am using Facebook Connect for iPhone and following the official instructions. I use the following code to display the login dialog: FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:...

Facebook App Profile Tab is Empty ... No Content Displayed?

I can view my application via the http://apps.facebook.com/myapplication/ link and the content shows up correctly. I also added the application as a tab to a facebook page. However, when viewing the ...

Facebook Platform error: "Object cannot be liked"

I m working on a Facebook Application that generates wall posts. In testing these posts, I ve discovered that the Facebook Platform action of "liking" a post is failing. The specific error message ...

how to call showPermissionsDialog() in php (facebook api)?

I was reading over the documentation yet I could not figure out how to call Facebook.showPermissionsDialog() in php include_once ./facebook-platform/php/facebook.php ; $facebook = new Facebook(my ...

Facebook connect

If I plug in the facebook connect into my website, How can I prevent double signups? Lets say I have a user that s already signed up to my site but he clicked the connect with facebook, is there a ...

热门标签