How can I get Facebook Profile image from email?

前端 未结 5 1006
囚心锁ツ
囚心锁ツ 2020-12-24 08:57

There\'s an outlook plugin called Xobni that has a really cool feature, if a contact has an email address, it will fetch that contact\'s profile picture and display it. Thei

5条回答
  •  滥情空心
    2020-12-24 09:54

    I am searching for a way to do this exact thing... No attempts have worked yet.

    Has anyone been able to find a solution?

    Update: I've put together this snippet in PHP. It's just about the only way I've been able to accomplish my goal. I'm not sure how Xobni is doing it (I'm sure they are less intrusive about it)

    loadHTML($response);
    
        /* What we are looking for */
        $match = 'http://www.facebook.com/profile.php?id=';
    
        /* Facebook UIDs */
        $uids = array();
    
        /* Find all Anchors */
        $anchors = $dom->getElementsByTagName('a');
        foreach ($anchors as $anchor) {
            $href = $anchor->getAttribute('href');
            if (stristr($href, $match) !== false) {
                $uids[] = str_replace($match, '', $href);
            }
        }
    
        /* Found Facebook Users */
        if (!empty($uids)) {
    
            /* Return Unique UIDs */
            $uids = array_unique($uids);
    
            /* Show Results */
            foreach ($uids as $uid) {
    
                /* Profile Picture */
                echo '' . $uid . '';
    
            }
    
        }
    
    }
    
    
    ?
    

提交回复
热议问题