列出Facebook喜欢在每个网址下面 [英] List facebook likes underneath every url
问题描述
我正在尝试找到最好的方式来计算一个Facebook页面网址的喜欢次数,并在谷歌搜索很多,玩代码之后,我有一个像下面给出的代码。它输出喜欢的页面的名称,然后链接。我想知道:
1.如何使用html标签将链接转换为超链接,以便我可以有一个像点击这里访问
2.如何监控25+的性能fb_id以小时为单位,按喜好排序顺序(降序)
<?php
$ fb_id =' 36922302396' ;
$ url ='https://graph.facebook.com/'。进行urlencode($ fb_id);
$ result = json_decode(file_get_contents($ url));
printf(%s%s%s,$ result-> likes,$ result-> name,$ result-> link);
?>
根据提供的解决方案编辑的代码
<?php
$ fb_id ='36922302396';
$ pic ='https://www.facebook.com/'。 urlencode($ fb_id)。 ?/画面类型=正方形;
$ url ='https://graph.facebook.com/'。进行urlencode($ fb_id);
$ result = json_decode(file_get_contents($ url));
echo $ result->喜欢,,$ result-> name,,< a target ='_ blank'href = \$ result-> link。 \\>< img src = $ pic>< / a>;
?>
感谢
对于1)
如何
;?php
$ fb_id ='36922302396';
$ url ='https://graph.facebook.com/'。进行urlencode($ fb_id);
$ result = json_decode(file_get_contents($ url));
// printf(%s%s%s,$ result-> likes,$ result-> name,$ result-> link);
echo< a href = \$ result-> link。\> Link< / a>;
?>
您还可以使用
< a href =https://www.facebook.com/<?php $ fb_id?>>链接< / a>
对于2)
如果你知道该页面的ID,那么您可以将它们连接到以下内容:
GET /?ids = 40796308305,339150749455906& fields = id ,name,likes,talking_about_count
结果如下:
{
/ pre>
40796308305:{
id:40796308305,
name:可口可乐 ,
喜欢:88365218,
talking_about_count:635936
},
339150749455906:{
id:339150749455906,
name:百事可乐,
喜欢:33321925,
talking_about_count:208761
}
}
对于小时数据,您需要通过
cron
等设置脚本,并将结果写入数据库。I was trying to find the best way to count number of likes for a facebook page url and after googling a lot and playing with the code, i have a code like the one given below. It outputs the likes, name of the page and then the link. I wish to know: 1. How can i use the html tag to convert the link into hyperlink so that I can have something like "Click here to visit" 2. How can monitor performance of 25+ fb_id on an hourly basis with a sorted order (descending) on likes
<?php $fb_id = '36922302396'; $url = 'https://graph.facebook.com/' . urlencode($fb_id); $result = json_decode( file_get_contents($url) ); printf("%s %s %s", $result->likes, $result->name, $result->link); ?>
Edited code as per solution provided
<?php $fb_id = '36922302396'; $pic = 'https://www.facebook.com/' . urlencode($fb_id) . '/picture?type=square'; $url = 'https://graph.facebook.com/' . urlencode($fb_id); $result = json_decode( file_get_contents($url) ); echo $result->likes , " " , $result->name , " " , "<a target='_blank' href=\"" . $result->link . "\" ><img src = $pic></a>"; ?>
Thanks
解决方案For 1)
How about
<?php $fb_id = '36922302396'; $url = 'https://graph.facebook.com/' . urlencode($fb_id); $result = json_decode( file_get_contents($url) ); //printf("%s %s %s", $result->likes, $result->name, $result->link); echo "<a href=\"" . $result->link . "\">Link</a>"; ?>
You can also use
<a href="https://www.facebook.com/<?php $fb_id ?>">Link</a>
For 2)
If you know the Page's IDs, then you can just concatenate them to the following :
GET /?ids=40796308305,339150749455906&fields=id,name,likes,talking_about_count
The result looks like the following
{ "40796308305": { "id": "40796308305", "name": "Coca-Cola", "likes": 88365218, "talking_about_count": 635936 }, "339150749455906": { "id": "339150749455906", "name": "Pepsi", "likes": 33321925, "talking_about_count": 208761 } }
For hourly stats, you need to setup your script via
cron
etc. and write the results to a database.这篇关于列出Facebook喜欢在每个网址下面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!