First you need the Facebook SDK bundle that contains base_facebook.php, facebook.php and fb_ca_chain_bundle.crt . You will also need fbmain.php and config.php .
Next you should have a file (e.g postToWall.php) that includes fbmain.php
<?php
include_once "fbmain.php";
?>
An example of postToWall.php file.
<html>
<body id="my_body">
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: '<?php echo $facebook->getAppID() ?>',
cookie: true,
xfbml: true,
oauth: true
});
FB.Canvas.setAutoGrow();
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
<?php
if ($me)
{
$params = array('message' => "message here",
'picture' => "picture hyperlink here",
'name' => "name here",
'link' => "facebook page hyperlink here",
'description' => " description here"
);
$status = $facebook->api('/me/feed', 'POST', $params);
if (isset($status['id']))
{
//do something
}
}
?>
</body>
</html>
Credits to my tutor, Mr Zen Leow
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…