Да задам още малко въпроси, поствам въпроса ми от форума на ФБ
Hi there,
I've been dealing with an iframe application, and I need to ask for user's permission to post feed on their walls.
So I use FB.Connect.streamPublish. But that's the thing - I can't seem to use it when I submit a form, only when a load the page the prompt apears.
Here is the code bellow :
That's the php part
<form action="" method="post" enctype="multipart/form-data" name="vote" onsubmit="return eho()">
<input type="text" name="name"/>
<input type="submit" name="publish" value="VOTE FOR ME!" />
</form>
And here is the JavaScript
<script src="
http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/bg_BG"
type="text/javascript"></script>
<script type="text/javascript">
FB_RequireFeatures(["XFBML"], function(){
FB.Facebook.init("48641a9cfb11d6ab8d6ebbfb8ce2661d", "xd_receiver.htm");
FB.CanvasClient.startTimerToSizeToContent(); //auto resize the height of the page
FB.CanvasClient.syncUrl(); // give you the users opportunity to use the Back button of the browser
FB.Connect.streamPublish();
});
</script> This is ok - it works, but when I put FB.Connect.streamPublish in a function - like this
function validateForm(){
var attachment = {'media': [{'type':'image',
'src':'image.jpg',
'caption': '{*actor*} voted their top5 sites!'}]};
var text = document.vote.name.value;
FB.Connect.streamPublish(text, attachment);
}
The FB.Connect.streamPublish doesn't execute, I'm sure that the function validateForm is called properly.
What I've tried is to but in a function the first piece of javascript - FB.init and so on, but it doesn't work as well.
Please, I need help asap. Thanks in advance. Have a nice day