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

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

问题描述

我正在使用Hammock库和C#从以下链接中获取用户的基本配置文件和电子邮件地址这里



我也跟着这些帖子这里这里



然而,对于我来说,我无法获取电子邮件地址linkedin用户。



阅读这个 linkedin的帖子我得到新的创建了一个新的应用程序来获取新的密钥,但仍然没有运气。



通过这个 linkedin的帖子,但是无法让它工作。



我正在发布下面的代码,但是由于我遵循的链接非常重要。

  var credentials = new OAuthCredentials 
{

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

ConsumerKey =我的用户密钥,//未显示

ConsumerSecret =我的消费者秘密,//未显示

Type = OAuthType.RequestToken,

};


var client = new RestClient
{
授权=https://api.linkedin.com/uas/oauth,
凭证=凭证
};

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

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

当用户导航到linkedin时,我得到这个屏幕。





实际上请求我使用这个代码的电子邮件

  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 =我的用户密钥,//未显示

ConsumerSecret = 我的消费者秘密,//未显示

Token = Session [AccessToken] ToString(),

TokenSecret = Session [AccessSecretToken] ToString ),

验证者=会话[验证者] ToString()

};


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


var MyInfo = client.Request(request);

String content = MyInfo.Content;

这是MyInfo.Content上的错误





谢谢提前为您的帮助。



在尝试Kamyar的建议时,我收到以下错误消息。我还应该尝试什么?



解决方案

我找到了解决方案。简单来说,请不要将?scope = r_emailaddres(或其他权限)包含到RestRequest的.Path属性中。
使用这样的东西:

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

(vb net syntax) >

.AddParameter方法是关键。


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

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

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

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",
                        };

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;

This is the error I get on MyInfo.Content

Thanks in advance for your help.

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

解决方案

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 net syntax)

.AddParameter method is the key.

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

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