首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从Facebook教育中提取大学-“教育”字段未被识别

从Facebook教育中提取大学-“教育”字段未被识别
EN

Stack Overflow用户
提问于 2012-07-21 00:12:16
回答 1查看 297关注 0票数 0

嗨,我正在尝试从他们的Facebook个人资料中提取用户的大学,并发现这篇文章很有用- Getting Education with Facebook Graph API in PHP

然而,在我的实现中,由于某些原因,'education‘字段没有被识别,并且在浏览器中抛出了一个错误“Undefined index: education”。这很奇怪,因为名字和姓氏和性别都可以很好地检索,但不能检索“教育”字段。

有人知道为什么会这样吗?

我的代码:

代码语言:javascript
运行
复制
// Get the app User ID
$user = $facebook->getUser();

if ($user) {
    try {
        // If the user has been authenticated then proceed
        $user_profile = $facebook->api('/me');

        // Extracting profile information to store in database
        $fname   = $user_profile['first_name'];
        $lname   = $user_profile['last_name'];
        $gender  = $user_profile['gender'];
        $email   = $user_profile['email'];
        $college = null;

        /* Education data is stored in an array so this iterates over
        the contents of that array and checks if the entry is for "College".  
        */

        foreach ($user_profile['education'] as $education) { // <-ERROR HERE
            if ($education['type'] == "College") {
                $college = $education;
                break;
            }
        }
    }
    catch (FacebookApiException $e) {
        error_log($e);
        $user = null;
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-07-21 00:21:18

在用户教育栏中,你可以看到facebook用户的学校名称、id和类型。只需在运行fql的变量中获取学校名称。欲了解更多信息,请访问:https://developers.facebook.com/docs/reference/fql/user/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11583149

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档