检索LinkedIn的电子邮件地址 [英] Retrieve Linkedin email address

查看:228
本文介绍了检索LinkedIn的电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的吊床库和C#来获得在下面的帖子的此处

I'm using the Hammock library and C# to get the basic profile and email address of user from linked in following post here .

我也跟着这些职位的这里和的这里

I've also followed these posts here and here

不过,对于我的生活,我不能让LinkedIn用户的电子邮件地址。

However for the life of me I cannot get the email address of the linkedin user.

这//开发商:通过的 LinkedIn后我得到了新创建了一个新的应用程序,以获得新钥匙但仍然没有运气

Reading this linkedin post I got new created a new application to get new keys however still no luck.

去了。 linkedin.com/forum/permission-scope-request-token-query-not-working~~V相对=nofollow>此内容 LinkedIn文章,但无法得到它的工作,要么

Went through this linkedin post but could not get it to work either

我张贴下面的代码,但它在很大程度上提升形式我跟着

I'm posting the code below but it's heavily lifted form the links I followed

var credentials = new OAuthCredentials
            {

                CallbackUrl = "http://localhost:2715/Callback.aspx",

                ConsumerKey = "my consumer key",//not shown

                ConsumerSecret = "my consumer secret",//not shown

                Type = OAuthType.RequestToken,

            };


        var client = new RestClient
            {
                Authority = "https://api.linkedin.com/uas/oauth",
                Credentials = credentials
            };

        //var scope = HttpUtility.UrlEncode("r_basicprofile r_emailaddress");

        var request = new RestRequest
                        {
                            Path = "requestToken?scope=r_basicprofile+r_emailaddress",
                        };



我得到这个画面,当用户浏览到LinkedIn。

I get this screen when user navigates to linkedin.

要实际上要求我使用下面

To actually request the email I use this code below

 var request = new RestRequest { Path = "people/~/email-address" };

        var credentials = new Hammock.Authentication.OAuth.OAuthCredentials

        {

            Type = OAuthType.AccessToken,

            SignatureMethod = OAuthSignatureMethod.HmacSha1,

            ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,

            ConsumerKey = "my consumer key", //not shown

            ConsumerSecret = "my consumer secret", //not shown

            Token = Session["AccessToken"].ToString(),

            TokenSecret = Session["AccessSecretToken"].ToString(),

            Verifier = Session["Verifier"].ToString()

        };


        var client = new RestClient()
        {
            Authority = "http://api.linkedin.com/v1/",
            Credentials = credentials,
            Method = WebMethod.Get
        };


        var MyInfo = client.Request(request);

        String content = MyInfo.Content;

这是我对MyInfo.Content获得

This is the error I get on MyInfo.Content

谢谢提前对您有所帮助。

Thanks in advance for your help.

在试图Kamyar的建议,我得到了以下错误消息。还有什么我应该尝试一下呢?

On trying Kamyar's suggestion I get the following error message. What else should I try?

推荐答案

我已经找到解决方案。简单地说,不包括?SCOPE = r_emailaddres(或其它权限)。路径RestRequest的财产。
使用是这样的:

I have found solution. Simply, do not include ?scope=r_emailaddres (or other permissions) to .Path property of RestRequest. Use something like this:

Dim request = New RestRequest With {.Path = "requestToken"}
request.AddParameter("scope", "r_emailaddress")

(VB净语法)

.AddParameter方法​​是关键。

.AddParameter method is the key.

这篇关于检索LinkedIn的电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆