Eli yksinkertaisesti miten saan aplikaation tulostamaan jotain käyttäjän seinälle? Ja käyttäen JS SDK:ta? Olen yrittänyt tehdä sen alla olevalla koodilla, mutta virheilmoitukseksi tulee koodista "Error occured" :/
Aplikaation sivu (index.php)
<!DOCTYPE html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
</head>
<body>
<a href="#" onClick="postToFacebook()">Post to Facebook</a>
<script>
function postToFacebook() {
var body = 'Reading Connect JS documentation';
FB.api('/me/feed', 'post', { body: body, message: 'My message is ...' }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response);
}
});
}
</script>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '1234567890',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
</body>
</html>EDIT: Koodin päivitys
Firebug debug info:
error
Object { message="An active access token must be used to query information about the current user.", type="OAuthException", code=2500}
code
2500
message
"An active access token must be used to query information about the current user."
type
"OAuthException"Eli:
An active access token must be used to query information about the current user.
Mihin väliin tuolla tarvii tuon active tokenin?
Käyttäjä pitää ensin autentikoida funktiolla FB.login.
Aihe on jo aika vanha, joten et voi enää vastata siihen.