โค้ดผมดูมาจากเว็บนี้ครับ
http://www.daydev.com/develope...age/facebook-open-graph-7.html ลองเอามาปรับใช้ดูมันก็ ERROR เลยครับ ผมต้องเปลี่ยนแปลงตรงไหนหรือเปล่าครับ ขอบคุณครับ
<?php
require 'src/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => 'APP ID',
'secret' => 'APP SECRET',
));
$scope='email,publish_actions,publish_stream,user_likes,user_photos,user_relationships,user_relationship_details,read_stream';
// Get User ID
$user = $facebook->getUser();
$access_token = $facebook->getAccessToken();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// Login or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl(array(
'scope' => $scope,
));
}
// This call will always work since we are fetching public data.
$daydev = $facebook->api('/daydevthailand');
?>
<!DOCTYPE>
<html xmlns:fb="http://ogp.me/ns/fb#">
<head>
<title>Facebook Open Graph API Examples by @daydev</title>
<meta charset="utf-8">
<link type="text/css" rel="stylesheet" href="styles/style.css" />
<!--[if IE 6]>
<script src="js/ie6-transparency.js"></script>
<script>DD_belatedPNG.fix('#wrap .line, #header #header-photo');</script>
<link rel="stylesheet" href="styles/ie6.css" />
<![endif]-->
<!--[if IE 7]><link rel="stylesheet" href="styles/ie7.css" /><![endif]-->
<!--[if IE 8]><link rel="stylesheet" href="styles/ie8.css" /><![endif]-->
<!--[if IE 9]><link rel="stylesheet" href="styles/ie9.css" /><![endif]-->
</head>
<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=406833949401207";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<script src="//connect.facebook.net/en_US/all.js"></script>
<div id="wrap">
<div id="header">
<?php if ($user) {?>
<div id="header-content">
<h2><a href="<?php echo $logoutUrl; ?>">Logout</a></h2>
<h1><?=$user_profile['name'];?></h1>
<h2>Profiles:</h2>
<p><?=$user_profile['bio']?></p>
<div id="contact-details">
<p class="contact"><span>Email: </span><?=$user_profile['email'];?></p>
<p class="contact"><span>Religion: </span><?=$user_profile['religion'];?></p>
<p class="contact"><span>Relation: </span><a href="http://www.facebook.com/<?=$user_profile['significant_other']['id'];?>"><?=$user_profile['significant_other']['name'];?></a></p>
</div>
</div>
<!--end header-content-->
<div id="header-photo" style="background-image:url(http://graph.facebook.com/<?=$user_profile["id"];?>/picture?type=large); background-repeat:no-repeat; width:170px; height:220px;"> </div>
<!--end header-photo-->
</div>
<!--end header-->
<?php }else{ ?>
<div id="header-content">
<a href="<?php echo $loginUrl; ?>">
<img src="images/facebook-connect-button.png" style="padding-bottom:20px;"/>
</a>
<h1>Please Login with Facebook</h1>
<h2>Your data will display</h2>
<p>Powered by <a href="http://twitter.com/daydev">@daydev</a> [Banyapon Poolsawasd] and Free-Css for Website Template</p>
<div id="contact-details">
<p class="contact"><span>Email: </span>daydevthaland@gmail.com</p>
<p class="contact"><span>Website: </span>[url=http://www.daydev.com]www.daydev.com[/url]</p>
</div>
</div>
<!--end header-content-->
<div id="header-photo" style="background-image:url(images/placeholder.png); background-repeat:no-repeat;"><img src="images/placeholder.png"/> </div>
<!--end header-photo-->
</div>
<!--end header-->
<?php } ?>
<div align="center">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-5951866056770179";
/* LeaderBoard */
google_ad_slot = "7899721000";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<div class="line"></div>
<div id="content">
<div id="experience" class="cv-section">
<h3>Experience</h3>
<?php
$source='[url]https://graph.facebook.com/'.[/url]$user_profile["id"].'?fields=feed&access_token='.$access_token.'&limit=30';
$jsource=file_get_contents($source);
$jsonfeed = json_decode($jsource);
foreach ($jsonfeed->feed->data as $data ) {
?>
<div class="cv-section-item">
<h4 class="title"><?php echo $data->from->name;?></h4>
<?php if(empty($data->message)){?>
<h4 class="meta"> </h4>
<?php }else{?>
<h4 class="meta">"<?php echo $data->message;?>"</h4>
<?php }?>
<img src="http://graph.facebook.com/<?php echo $data->from->id;?>/picture" style=" border:#006699 solid 5px;" align="left"/>
<?php if(empty($data->picture)){}else{?>
<img src="<?php echo $data->picture;?>" style="width:80px; margin-bottom:10px; border:#999999 solid 5px;" align="right"/>
<?php }?>
<div style="margin-left:65px; width:540px;"><p><?php echo date("d (D), M Y", strtotime($data->created_time));?></p>
<?php if(empty($data->name)){?>
<p>Shared some content! <a href="http://www.daydev.com" title="Social Media Marketing">Social Media Marketing</a></p>
<?php }else{ ?>
<p><a href="<?php echo $data->link;?>">"<?php echo $data->name;?>"</a></p> <p><?php echo $data->description;?></p>
<?php }?>
<?php if(empty($data->application->name)){}else{?>
<?php }?>
<p>
<?php foreach($data->likes->data as $valike){?>
<a href="http://www.facebook.com/<?php echo $valike->id;?>"><img src="http://graph.facebook.com/<?php echo $valike->id;?>/picture" style="float:left; padding-right:5px; width:24px; height:24px;"/></a>
<?php }?> <?php if(empty($data->likes->count)){}else{?>Likes: ( <?php echo $data->likes->count;?> )<?php }?></p>
</div>
<div class="line"></div>
<?php
foreach($data->comments->data as $values){
?>
<div style="margin-left:65px; width:540px; padding-left:5px; background-color:#EBEBEB; border:#999999 solid 1px; margin-top:15px; vertical-align:text-top;">
<a href="http://www.facebook.com/<?php echo $values->from->id;?>"><img src="http://graph.facebook.com/<?php echo $values->from->id;?>/picture" style="margin-right:10px; margin-top:5px; border:#999999 solid 5px;" align="right"/></a>
<h4>Comments by <a href="http://www.facebook.com/<?php echo $com_name=$values->from->id;?>"><?php echo $com_name=$values->from->name;?></a></h4>
<p><?php echo $com_message=$values->message;?></p>
</div>
<?php }?>
</div>
<!--end cv-section-item-->
<?php
}
?>
</div>
<!--end experience-->
<!--end education-->
<div class="line"></div>
<!--end training-->
</div>
<!--end content-->
</div>
<!--end wrap-->
<div id="spacing"></div>
<!--hack for ie6 and ie7-->
</body>
</html>