Find Facebook user (url to profile page) by known email address

后端 未结 11 1718
陌清茗
陌清茗 2020-12-01 03:40

I have an email address and want to find out if there is a Facebook user linked to this address. If there is, then I want to retrieve the url to this users profile page and

相关标签:
11条回答
  • 2020-12-01 04:23

    I've captured the communication of Outlook plugin for Facebook and here is the POST request

    https://api.facebook.com/method/fql.multiquery
    access_token=TOKEN&queries={"USER0":"select '0', uid, name, birthday_date, profile_url, pic, website from user where uid in (select uid from email where email in ('EMAIL_HASH'))","PENDING_OUT":"select uid_to from friend_request where uid_from = MY_ID and (uid_to IN (select uid from #USER0))"}
    

    where
    TOKEN - valid access token
    EMAIL_HASH - combination of CRC32 and MD5 hash of searched email address in format crc32_md5
    MY_ID - ID of facebook profile of access token owner

    But when I run this query with different access token (generated for my own application) the server response is: "The table you requested does not exist" I also haven't found the table email in Facebook API documentation. Does Microsoft have some extra rights at Facebook?

    0 讨论(0)
  • 2020-12-01 04:23

    Andreas, I've also been looking for an "email-to-id" ellegant solution and couldn't find one. However, as you said, screen scraping is not such a bad idea in this case, because emails are unique and you either get a single match or none. As long as Facebook don't change their search page drastically, the following will do the trick:

    final static String USER_SEARCH_QUERY = "http://www.facebook.com/search.php?init=s:email&q=%s&type=users";
    final static String USER_URL_PREFIX = "http://www.facebook.com/profile.php?id=";
    
    public static String emailToID(String email)
    {
        try
        {
            String html = getHTML(String.format(USER_SEARCH_QUERY, email));
            if (html != null)
            {
                int i = html.indexOf(USER_URL_PREFIX) + USER_URL_PREFIX.length();
                if (i > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    char c;
                    while (Character.isDigit(c = html.charAt(i++)))
                        sb.append(c);
                    if (sb.length() > 0)
                        return sb.toString();
                }
            }
        } catch (Exception e)
        {
            e.printStackTrace();
        }
        return null;
    }
    
    private static String getHTML(String htmlUrl) throws MalformedURLException, IOException
    {
        StringBuilder response = new StringBuilder();
        URL url = new URL(htmlUrl);
        HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
        httpConn.setRequestMethod("GET");
        if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK)
        {
            BufferedReader input = new BufferedReader(new InputStreamReader(httpConn.getInputStream()), 8192);
            String strLine = null;
            while ((strLine = input.readLine()) != null)
                response.append(strLine);
            input.close();
        }
        return (response.length() == 0) ? null : response.toString();
    }
    
    0 讨论(0)
  • 2020-12-01 04:23

    First I thank you. # 57ar7up and I will add the following code it helps in finding the return phone number.

    function index(){
        // $keyword = "0946664869";
        $sql = "SELECT * FROM phone_find LIMIT 10";
        $result =  $this->GlobalMD->query_global($sql);
        $fb = array();
        foreach($result as $value){
            $keyword = $value['phone'];
            $fb[] = $this->facebook_search($keyword);
        }
        var_dump($fb);
    
    }
    
    function facebook_search($query, $type = 'all'){
        $url = 'http://www.facebook.com/search/'.$type.'/?q='.$query;
        $user_agent = $this->loaduserAgent();
    
        $c = curl_init();
        curl_setopt_array($c, array(
            CURLOPT_URL             => $url,
            CURLOPT_USERAGENT       => $user_agent,
            CURLOPT_RETURNTRANSFER  => TRUE,
            CURLOPT_FOLLOWLOCATION  => TRUE,
            CURLOPT_SSL_VERIFYPEER  => FALSE
        ));
        $data = curl_exec($c);
        preg_match('/\&#123;&quot;id&quot;:(?P<fbUserId>\d+)\,/', $data, $matches);
        if(isset($matches["fbUserId"]) && $matches["fbUserId"] != ""){
            $fbUserId = $matches["fbUserId"];
            $params = array($query,$fbUserId);
        }else{
            $fbUserId = "";
            $params = array($query,$fbUserId);
        }
        return $params;
    }
    
    0 讨论(0)
  • 2020-12-01 04:29

    The definitive answer to this is from Facebook themselves. In post today at https://developers.facebook.com/bugs/335452696581712 a Facebook dev says

    The ability to pass in an e-mail address into the "user" search type was
    removed on July 10, 2013. This search type only returns results that match
    a user's name (including alternate name).
    

    So, alas, the simple answer is you can no longer search for users by their email address. This sucks, but that's Facebook's new rules.

    0 讨论(0)
  • 2020-12-01 04:30

    Maybe things changed, but I recall rapleaf had a service where you enter an email address and you could receive a facebook id.
    https://www.rapleaf.com/

    If something was not in there, one could "sign up" with the email, and it should have a chance to get the data after a while.

    I came across this when using a search tool called Maltego a few years back.
    The app uses many types of "transforms", and a few where related to facebook and twitter etc..

    ..or find some new sqli's on fb and fb apps, hehe. :)

    0 讨论(0)
提交回复
热议问题