protected void Page_Load(object sender, EventArgs e)
        {
            // create from config file
            var config = LinkedInApiConfiguration.FromAppSettings("MyDemo.LinkedInConnect");
            // or manually
            //  var config = LinkedInApiConfiguration("api key", "api secret key");

            // get the APIs client
            var api = new LinkedInApi(config);

            var scope = AuthorizationScope.ReadBasicProfile | AuthorizationScope.ReadEmailAddress;
            var state = Guid.NewGuid().ToString();
            var redirectUrl = "http://localhost:49965/WebForm1.aspx";
            var url = api.OAuth2.GetAuthorizationUrl(scope, state, redirectUrl);

            Response.Redirect(url.OriginalString);
        }
Beispiel #2
0
 // http://davideguida.altervista.org/mvc-reading-linkedin-user-profile-data/
 // https://github.com/SparkleNetworks/LinkedInNET
 //public RedirectResult Profile()
 //{
 //    var redirectUrl = "http://mydomain/linkedin/profilereturn/";
 //    var url = GetAuthorizationUrl(redirectUrl);
 //    return Redirect(url.ToString());
 //}
 private static LinkedInApi CreateAPI()
 {
     var config = new LinkedInApiConfiguration("77ck1ulnz4e5yh", "olqES8j6K3uXJMNg");
     var api = new LinkedInApi(config);
     return api;
 }
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Request.QueryString["code"] != null)
            {
                var accessCode = Request.QueryString["code"]; // save this code for each user in db and use this code for 
                // further accessing 
                var redirectUrl = "http://localhost:49965/WebForm1.aspx";

                // this section of code is using to access the web

                var config = LinkedInApiConfiguration.FromAppSettings("MyDemo.LinkedInConnect");

                var api = new LinkedInApi(config);

                var userToken = api.OAuth2.GetAccessToken(accessCode, redirectUrl);

                var user = new UserAuthorization(userToken.AccessToken);
                string culture = "en-US";
                var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };
                var fields = FieldSelector.For<Person>()
                    .WithId()
                    .WithFirstName()
                    .WithLastName()
                    .WithFormattedName()
                    .WithEmailAddress()
                    .WithHeadline()

                    .WithLocationName()
                    .WithLocationCountryCode()

                    .WithPictureUrl()
                    .WithPublicProfileUrl()
                    .WithSummary()
                    .WithIndustry()

                    .WithPositions()
                    .WithPositionsSummary()
                    .WithThreeCurrentPositions()
                    .WithThreePastPositions()

                    .WithProposalComments()
                    .WithAssociations()
                    .WithInterests()
                    .WithLanguageId()
                    .WithLanguageName()
                    .WithLanguageProficiency()
                    .WithCertifications()
                    .WithEducations()
                    .WithFullVolunteer()
                    .WithPatents()
                    ////.WithRecommendationsReceived() // may not use that
                    .WithRecommendationsReceivedWithAdditionalRecommenderInfo()

                    .WithDateOfBirth()
                    .WithPhoneNumbers()
                    .WithImAccounts()
                    .WithPrimaryTwitterAccount()
                    .WithTwitterAccounts()
                    .WithSkills();

                var profile = api.Profiles.GetMyProfile(user, acceptLanguages, fields);

                var firstName = profile.Firstname;


                var lastName = profile.Lastname;


                var emailAddress = profile.EmailAddress;


                var headine = profile.Headline;


                var location = profile.Location.Name;


                var industry = profile.Industry;


                var dateOfDirth = profile.DateOfBirth;
            }

        }