在网页上显示公开的Facebook活动 [英] Display a public Facebook event on a web page
问题描述
如何从网页上的特定Facebook活动中显示信息?
How can I show information from a specifiec Facebook event on a webpage?
如:时间,位置,创建者,更多信息以及使用的图像作为缩略图。
Things like: time, location, created by, more info, and also the image used as thumbnail.
即使我没有创建该事件。
Even if I didn't created that event.
其他人创建了它。
我刚刚拥有该Facebook活动的网址,我可以找到创建该活动的人的用户ID。
I just have the url of that Facebook event and I can find the user id of the person who created it.
我发现这个页面:
http://www.codeofaninja.com/2011/07/display-facebook-events-to-your-website.html
但不是和我想要的一样,我无法弄清楚如何做到这一点。
But it's not the same as I want, and I couldn't figure it out how to do it.
非常感谢任何帮助。
推荐答案
程序在?说php或javascript,我会发一个快速样品?
What languages do you program in? say php or javascript, and i will post a quick sample?
您可以使用许多SDK中的一个,但对我来说,最容易使用的是php-sdk和javascript-sdk。
You can use one of the many SDK's but for me the 2 that are easiest to use are the php-sdk and javascript-sdk.
https://developers.facebook.com/docs/sdks/
使用任何一个,您只需向图表api发送一个请求,就可以通过其ID来检索有关该事件的信息。
Using either you can just send a request to the graph api to retrieve the info about the event by its id.
https://developers.facebook.com/docs/reference/api/
https: //developers.facebook.com/docs/reference/api/event/
<?php
$pageid='YourPageId.or.AppId';
$MEevents = $facebook->api('/'.$pageid.'/events?access_token='.$app_access_token.'&fields=id,name,from,start_time,location,end_time&limit=8');
echo '<div align="center" style="border: 0px solid; width: 100%;">';
foreach ($MEevents as $key=>$value) {
$i=1;
foreach ($value as $fkey=>$fvalue) {
if($fvalue[id]==h){
}else{
$i++;
$whofrom = $fvalue[from];
$whofromname = $whofrom[name];
$whofrompic = $whofrom[id];
echo '<div title="'.$fvalue[name].'" style="vertical-align: top; border: 1px inset; width: 700px; min-height: 80px; margin: 2px;">';
echo '<div id=""></div>';
echo '<div style="margin: 4px; padding: 3px; text-align: left;">';
echo '<img src="https://graph.facebook.com/'.$fvalue[id].'/picture" style="float: left; clear: left; margin: 5px;"> ';
echo '<a href="https://www.facebook.com/event.php?eid='.$fvalue[id].'" target="_blank">'.$fvalue[name].'</a><br />';
echo 'Location: '.$fvalue[location].'<br />';
echo 'Starts '.nicetime($fvalue[start_time]).' - Ends '.nicetime($fvalue[end_time]).'<br />';
echo '</div>';
echo '</div>';
}
}
}
echo '</div>';
?>
这篇关于在网页上显示公开的Facebook活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!