Exemplo n.º 1
0
        /// <summary>
        /// Get User Info
        /// </summary>
        /// <param name="code"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public ProfileInfo GetUserInfo(string code, string state)
        {
            var userProfilinfo = new ProfileInfo();
            var Accesstoan     = linkedIn.GetAccessToken(code, WebConfigurationManagement.LinkedinRedirect_uri);

            if (Accesstoan.Status == LinkedInResponseStatus.OK)
            {
                LinkedInGetMemberOptions lnoption = new LinkedInGetMemberOptions();
                lnoption.BasicProfileOptions.SelectAll();
                lnoption.EmailProfileOptions.SelectAll();
                lnoption.FullProfileOptions.SelectAll();
                var Userinfo = linkedIn.GetMember(lnoption);
                if (Userinfo.Status == LinkedInResponseStatus.OK)
                {
                    userProfilinfo.FirstName = linkedIn.CurrentUser.FirstName;
                    userProfilinfo.LastName  = linkedIn.CurrentUser.LastName;
                    //  userProfilinfo.Phone = Userinfo.Result.BasicProfile.PhoneticFirstName;
                    userProfilinfo.ProfilePicture = ((LinkedIn.NET.Members.LinkedInPerson)(Userinfo.Result.BasicProfile)).PictureUrl;
                    userProfilinfo.ProfileURL     = Userinfo.Result.BasicProfile.PublicProfileUrl;
                    userProfilinfo.Email          = Userinfo.Result.EmailProfile.EmailAddress;
                    userProfilinfo.IsSuccess      = true;
                }
                else
                {
                    userProfilinfo.IsSuccess    = false;
                    userProfilinfo.ErrorMessage = Userinfo.Message;
                }
            }
            else
            {
                userProfilinfo.IsSuccess    = false;
                userProfilinfo.ErrorMessage = Accesstoan.Message;
            }
            return(userProfilinfo);
        }
Exemplo n.º 2
0
        internal static string PrepareMemberFields(LinkedInGetMemberOptions options)
        {
            var fields = new StringBuilder();

            var addFields = options.BasicProfileOptions.HasValues | options.EmailProfileOptions.HasValues |
                            options.FullProfileOptions.HasValues;

            if (addFields)
            {
                fields.Append(":(");
            }

            if (options.BasicProfileOptions.HasValues)
            {
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.Id])
                {
                    fields.Append("id,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.FirstName])
                {
                    fields.Append("first-name,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.LastName])
                {
                    fields.Append("last-name,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.MaidenName])
                {
                    fields.Append("maiden-name,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.FormattedName])
                {
                    fields.Append("formatted-name,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.PhoneticFirstName])
                {
                    fields.Append("phonetic-first-name,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.PhoneticLastName])
                {
                    fields.Append("phonetic-last-name,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.FormattedPhoneticName])
                {
                    fields.Append("formatted-phonetic-name,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.Headline])
                {
                    fields.Append("headline,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.Location])
                {
                    fields.Append("location,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.Industry])
                {
                    fields.Append("industry,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.Distance])
                {
                    fields.Append("distance,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.RelationToViewer])
                {
                    fields.Append("relation-to-viewer,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.CurrentShare])
                {
                    fields.Append("current-share,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.NumConnections])
                {
                    fields.Append("num-connections,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.NumConnectionsCapped])
                {
                    fields.Append("num-connections-capped,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.Summary])
                {
                    fields.Append("summary,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.Specialities])
                {
                    fields.Append("specialties,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.Positions])
                {
                    fields.Append("positions:(id,title,summary,start-date,end-date,is-current,company:(id,name,type,size,industry,ticker)),");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.PictureUrl])
                {
                    fields.Append("picture-url,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.SiteStandardProfileRequest])
                {
                    fields.Append("site-standard-profile-request,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.ApiStandardProfileRequest])
                {
                    fields.Append("api-standard-profile-request,");
                }
                if (options.BasicProfileOptions[LinkedInBasicProfileFields.PublicProfileUrl])
                {
                    fields.Append("public-profile-url,");
                }
            }
            if (options.EmailProfileOptions.HasValues)
            {
                if (options.EmailProfileOptions[LinkedInEmailProfileFields.EmailAddress])
                {
                    fields.Append("email-address,");
                }
            }
            if (options.FullProfileOptions.HasValues)
            {
                if (options.FullProfileOptions[LinkedInFullProfileFields.LastModifiedTimestamp])
                {
                    fields.Append("last-modified-timestamp,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.ProposalComments])
                {
                    fields.Append("proposal-comments,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.Associations])
                {
                    fields.Append("associations,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.Interests])
                {
                    fields.Append("interests,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.Publications])
                {
                    fields.Append("publications:(id,title,publisher,authors,date,url,summary),");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.Patents])
                {
                    fields.Append("patents:(id,title,summary,number,status,office,inventors,date,url),");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.Languages])
                {
                    fields.Append("languages:(id,language,proficiency),");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.Skills])
                {
                    fields.Append("skills,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.Certifications])
                {
                    fields.Append("certifications:(id,name,authority,number,start-date,end-date),");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.Educations])
                {
                    fields.Append("educations,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.Courses])
                {
                    fields.Append("courses,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.Volunteer])
                {
                    fields.Append("volunteer:(volunteer-experiences:(id,role,organization,cause)),");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.ThreeCurrentPositions])
                {
                    fields.Append("three-current-positions,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.ThreeLastPositions])
                {
                    fields.Append("three-past-positions,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.NumRecommenders])
                {
                    fields.Append("num-recommenders,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.RecommendationsReceived])
                {
                    fields.Append("recommendations-received,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.MfeedRssUrl])
                {
                    fields.Append("mfeed-rss-url,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.Following])
                {
                    fields.Append("following,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.JobBookmarks])
                {
                    fields.Append("job-bookmarks,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.Suggestions])
                {
                    fields.Append("suggestions,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.DateOfBirth])
                {
                    fields.Append("date-of-birth,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.MemberUrlResources])
                {
                    fields.Append("member-url-resources,");
                }
                if (options.FullProfileOptions[LinkedInFullProfileFields.RelatedProfileViews])
                {
                    fields.Append("related-profile-views,");
                }
            }

            if (addFields)
            {
                if (fields.Length > 2)
                {
                    fields.Length -= 1;
                }
                fields.Append(")");
            }

            return(fields.ToString());
        }