How to post simple text to FB wall programmatically using HTML?
What I'd like to do is to post some simple text to a user's FB wall (with the user's ID already known to my app).
Have read quite a few posts about posting to FB wall, however, still stumbled.
From the sample code at a youtube video, I created a complete code set and posted to FB dev forum, the err msg I get is, "FB.getLoginStatus() called b开发者_JS百科efore calling FB.init()"
Here's the link of my code, http://forum.developers.facebook.net/viewtopic.php?id=94801
Note: We could use a simple HTML page for testing this...
What's wrong? Thanks.
Here's the source from my project's facebook test page, containing complete implementations of a few common facebook tasks. The only thing redacted is the facebook app ID. Obviously, you don't have our libs but in this case they just verify the session and draw headers.
<html>
<head>
<meta charset="UTF-8" />
<title>phyre Lux Client</title>
<script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="../js/jquery-ui-1.8.5.custom.min.js"></script>
<script type="text/javascript" src="../phyrelib-clientside.js"></script>
<link type="text/css" href="../css/custom-theme/jquery-ui-1.8.5.custom.css" rel="stylesheet">
<link type="text/css" href="../css/phyre.css" rel="stylesheet">
<script src="js/typeface.js"></script>
<script src="js/cicle_fina.typeface.js"></script>
</head>
<body onLoad='return 0;' id='luxDocBody' class='phyremodule'>
<div id='fb-root'></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script type='text/javascript'>
FB.init({appId: 'REDACTED', status: true, cookie: true, xfbml: true});
FB.Event.subscribe('auth.sessionChange', function(response) {
if (response.session) {
// A user has logged in, and a new cookie has been saved
alert('yay');
} else {
// The user has logged out, and the cookie has been cleared
alert('nay');
}
});
FB.ui(
{
method: 'stream.publish',
message: 'getting educated about Facebook Connect',
attachment: {
name: 'Connect',
caption: 'The Facebook Connect JavaScript SDK',
description: (
'A small JavaScript library that allows you to harness ' +
'the power of Facebook, bringing the user\'s identity, ' +
'social graph and distribution power to your site.'
),
href: 'http://github.com/facebook/connect-js'
},
action_links: [
{ text: 'Code', href: 'http://github.com/facebook/connect-js' }
],
user_message_prompt: 'Share your thoughts about Connect'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
FB.getLoginStatus(function(response) {
if (response.session) {
// logged in and connected user, someone you know
alert('yay');
} else {
// no user session available, someone you dont know
alert('nay');
}
});
</script>
<fb:login-button></fb:login-button>
</body>
</html>
精彩评论