I am using bellow code which is in a '.php' file, to publish stream.
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init(
{
appId : 'MY_APP_ID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
var publish = {
method: 'stream.publish',
message: '',
picture : 'http://www.associationregion.org/images/stories/slides/Upload.png',
link : 'http://apps.facebook.com/puzzlegts/',
name: 'Go to image',
caption: 'taged you in a photo',
description: 'test 2',
actions : { name : 'Go to app', link : 'http://apps.facebook.com/puzzlegts/'}
};
FB.api('/me/feed', 'POST', publish, function(response) {alert("posted");});
</script>
Now I have a javascript file named 'publish.js' and I want to add publish stream method to a function in my 'publish.js' file. Can anyone please tell me how to do this?
Problem arise since I can't use '<script>
' tag in a '.js' file.Therefore I can't include bellow code.
<script src="http://connect.facebook.net/en_US/all.js"></script>
Or can anyone please post the suitable code for a '.js' file
Add this to your page
and add this to your publish.js
(without script tags)
You have add it programmatically then or just use the asynchronous loading:
Notes:
fb-root
div is in your markupall.js
is fully loaded