我刚刚开始学习 facebook 应用程序开发,如果它是一个字符串,我需要按名称获取 facebook 组 id,如果它的数字是(整数)。现在,我到目前为止所做的是:
if(isset($_POST['scrape'])):
$group_id = $_POST['gid'];
if(!(int)$group_id)
{
$fb_group_array = file_get_contents("http://graph.facebook.com/".$group_id);
}
endif;
其中 $fb_group_array 输出如下内容:
{
"is_published": true,
"personal_info": "This group is where u Share Adult Jokes and Funny pictures.\nOnly \" BOYS \" with real identity are welcome to the group.\n( RULE: NO FIGHTS BETWEEN OUR BROTHERS, RESPECT; BEHAVE AND SALUTE to our BROTHERHOOD )\n(NOTE: ADULT CONTENTS, 18+ ONLY, GIRLS AND GAYS PROHIBITED)\nThank you. :)",
"talking_about_count": 0,
"username": "MENSROOMrELOADED",
"were_here_count": 0,
"category": "Public figure",
"id": "429748430401621",
"name": "M E N S R O O M (r E L O a D E D )",
"link": "https://www.facebook.com/MENSROOMrELOADED",
"likes": 137
}
现在我想从这个输出中提取数据作为 id、用户名等。我尝试爆炸它们并且它工作得很好但是我确信有更好的方法来做到这一点,比如转换为 PHP 数组或 JSON。请引导我走向正确的方向。谢谢你。