php - 我想访问此页面的关注者,但它只显示这么多数据
问题描述
我正在尝试访问此页面的关注者/喜欢者,但它只显示这么多数据。我如何访问此页面的所有信息。
类别“实用程序”链接“ http://localhost/cricshots/ ”名称“cricketshotsofficial”id“1996682000635998”
尝试使用以下代码获取访问权限:
$json_url = 'https://graph.facebook.com/' . $facebook_page_id.'?access_token=' . $access_token ;
期望输出是此页面的完整详细信息或仅是该页面的关注者
解决方案
这是一个更新且有效的代码片段,可用于检索特定页面的 Facebook 点赞数。要使用此代码段,您需要 Facebook 应用 ID 和密钥。
<?php
function fbLikeCount($id,$appid,$appsecret){ // $id = Fb Page id
$json_url ='https://graph.facebook.com/'.$id.'?access_token='.$appid.'|'.$appsecret.'&fields=fan_count';
$json = file_get_contents($json_url);
$json_output = json_decode($json);
//Extract the likes count from the JSON object
if($json_output->fan_count){
return $fan_count = $json_output->fan_count;
}else{
return 0;
}
}
echo fbLikeCount('coregenie','___APPID___','___APPSECRET___');
?>
请编辑您的页面名称、应用程序 ID、应用程序密码。
推荐阅读
- mysql - MySQL,WHERE 子句中的 IF 语句?
- android - 替换以(最好不使用 sed)开头的字符串
- javascript - jQuery DataTables - 调用多个插件?(日期范围/范围搜索)
- python - 马修特征值
- prisma - Prisma - 如何使用多个模型中的字段定义复合唯一约束?
- java - springdoc-openapi、swagger UI 中的 XML 示例
- sql - SQL 查找多个条件的最后一个值
- r - 添加时间间隔的无暴露时段(间隙)的行
- c++ - 调用 movetothread() 后如何停止 Qthread?
- javascript - 一个组件的导出功能并在另一个组件中使用