开发者

Get userid in facebook from its e-mail using c#

开发者 https://www.devze.com 2023-03-20 04:06 出处:网络
I am using Facebook API how i can get userid in facebook from its mail ? I am u开发者_如何学Gosing Facebook.dllUsing a Search API, you can query all publicly available information. That means, you ca

I am using Facebook API how i can get userid in facebook from its mail ?

I am u开发者_如何学Gosing Facebook.dll


Using a Search API, you can query all publicly available information. That means, you can get user ID if the user allowed his e-mail address to be public.
You would issue a query something like:

 https://graph.facebook.com/search?q=user@example.com&type=user&access_token=... 

The JSON response would be:

{
      "data": [
        {
         "name": "Firstname Lastname"
         "id": "123456799"
        }
   ]
} 

If the user's address is not public, you will get an empty data.

I'm not aware if there is an implementation for this in C#, but you can easily make one.


dynamic result = fb.Get("/search", parameters);

should be changed into something like:

dynamic result = fb.Get("/me", parameters);


Here is how you would do it using Facebook C# SDK.

var fb = new FacebookClient("access_token");
dynamic parameters = new ExpandoObject();
parameters.q = "user@example.com";
parameters.type = "user";
dynamic result = fb.Get("/search", parameters);

If user is found you will get exactly one result.

if(result.data.Count == 1){
    var uid = result.data[0].id;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消