有一个名为Xobni的outlook插件,它有一个非常酷的功能,如果一个联系人有一个电子邮件地址,它将获取该联系人的个人资料图片并显示它.他们的FAQ说明如下:
Xobni向Facebook发送加密的电子邮件地址,以检索当前正在Xobni边栏中查看的人的Facebook个人资料.您自己的Facebook个人资料永远不会被Xobni更改,并且在查看其他个人资料时会严格遵守所有Facebook隐私设置.
我想复制这个功能.但是,我无法确定他们正在使用哪个API调用.我假设当他们说"加密的电子邮件地址"时,这是电子邮件哈希的外行人的条款.一旦导出了用户名,图形api看起来非常适合实际获取图像,但是我无法从电子邮件哈希转到配置文件ID.
Ser*_*lov 13
您可以查询以下URL以获取用户ID(如果Facebook上存在用户ID):
https://graph.facebook.com/search?access_token=YOUR_ACCESS_TOKEN&q=EMAIL_ADDRESS_URL_ENCODED&type=user
Run Code Online (Sandbox Code Playgroud)
然后<img src="https://graph.facebook.com/USER_ID/picture">给你的照片.
更多信息:codinglogs.com上的文章
小智 3
我正在寻找一种方法来完成这件事......尚未尝试过。
有人能找到解决方案吗?
更新:我已经用 PHP 编写了这个片段。这几乎是我实现目标的唯一方法。我不确定 Xobni 是如何做到这一点的(我确信他们不会那么干涉)
<?php
/* Email to Search By */
$eml = 'user@domain.com';
/* This is where we are going to search.. */
$url = 'http://www.facebook.com/search.php?q=' . urlencode($eml);
/* Fetch using cURL */
$ch = curl_init();
/* Set cURL Options */
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
/* Tell Facebook that we are using a valid browser */
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13');
/* Execute cURL, get Response */
$response = curl_exec($ch);
/* Check HTTP Code */
$response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
/* Close cURL */
curl_close($ch);
/* 200 Response! */
if ($response_code == 200) {
/* Parse HTML Response */
$dom = new DOMDocument();
@$dom->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 '<img src="http://graph.facebook.com/' . $uid. '/picture" alt="' . $uid . '" />';
}
}
}
?
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10854 次 |
| 最近记录: |