Ejemplo n.º 1
0
        public async Task <ActionResult> Index(string culture = "en-US")
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            // step 1: configuration
            ViewBag.Configuration = apiConfig;

            // step 2: authorize url
            var scope       = AuthorizationScope.ReadEmailAddress | AuthorizationScope.ReadWriteCompanyPage | AuthorizationScope.WriteShare;
            var state       = Guid.NewGuid().ToString();
            var redirectUrl = Request.Compose() + Url.Action("OAuth2");

            ViewBag.LocalRedirectUrl = redirectUrl;
            if (apiConfig != null && !string.IsNullOrEmpty(apiConfig.ApiKey))
            {
                var authorizeUrl = api.OAuth2.GetAuthorizationUrl(scope, state, redirectUrl);
                ViewBag.Url = authorizeUrl;
            }
            else
            {
                ViewBag.Url = null;
            }

            var accessToken = "";

            data.SaveAccessToken(accessToken);


            // step 3
            if (data.HasAccessToken)
            {
                var token = data.GetAccessToken();
                ViewBag.Token = token;
                var user = new UserAuthorization(token);

                var watch = new Stopwatch();
                watch.Start();
                try
                {
                    var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };
                    var fields          = FieldSelector.For <Person>().WithAllFields();
                    var profile         = await api.Profiles.GetMyProfileAsync(user, acceptLanguages, fields);

                    ViewBag.Profile = profile;
                }
                catch (LinkedInApiException ex)
                {
                    ViewBag.ProfileError = ex.ToString();
                }
                catch (Exception ex)
                {
                    ViewBag.ProfileError = ex.ToString();
                }

                watch.Stop();
                ViewBag.ProfileDuration = watch.Elapsed;
            }

            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult SearchCompany(string keywords, int start = 0, int count = 20, string facet = null)
        {
            var token  = this.data.GetAccessToken();
            var user   = new UserAuthorization(token);
            var fields = FieldSelector.For <CompanySearch>()
                         .WithFacets()
                         .WithCompaniesDescription().WithCompaniesId()
                         .WithCompaniesLogoUrl().WithCompaniesName()
                         .WithCompaniesSquareLogoUrl().WithCompaniesStatus()
                         .WithCompaniesWebsiteUrl()
                         .WithCompaniesUniversalName();

            CompanySearch result;

            if (!string.IsNullOrEmpty(facet))
            {
                result = this.api.Companies.FacetSearch(user, start, count, keywords, facet, fields);
            }
            else
            {
                result = this.api.Companies.Search(user, start, count, keywords, fields);
            }

            this.ViewBag.keywords = keywords;
            this.ViewBag.start    = start;
            this.ViewBag.count    = count;
            this.ViewBag.facet    = facet;

            return(this.View(result));
        }
Ejemplo n.º 3
0
        public ActionResult Person(string id, string culture = "en-US")
        {
            var token = this.data.GetAccessToken();

            this.ViewBag.Token = token;
            var user            = new UserAuthorization(token);
            var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };

            var fields = FieldSelector.For <Person>()
                         .WithId()
                         .WithPositions().WithPictureUrl()
                         .WithFirstName().WithLastName().WithHeadline()
                         .WithLanguageId().WithLanguageName().WithLanguageProficiency()
                         .WithConnections();
            var profile = this.api.Profiles.GetProfileById(user, id, acceptLanguages, fields);

            {
                var pictures = this.api.Profiles.GetOriginalProfilePicture(user, profile.Id)
                               ?? new PictureUrls()
                {
                    PictureUrl = new List <string>()
                };
                var more = this.api.Profiles.GetProfilePicture(user, profile.Id, 120, 120);
                if (more != null && more.PictureUrl != null)
                {
                    pictures.PictureUrl.AddRange(more.PictureUrl);
                }

                this.ViewBag.Pictures = this.ViewData["ProfilePictures"] = pictures;
            }

            return(this.View(profile));
        }
Ejemplo n.º 4
0
        public void FormatUrlWithSlashFieldSelector()
        {
            var target = new Api();
            var result = target.FormatUrlInvoke("a{FieldSelector}a", FieldSelector.For <object>().Add("site-standard-profile-request/url"));

            Assert.AreEqual("a:(site-standard-profile-request/url)a", result);
        }
Ejemplo n.º 5
0
        private static Person ReadMyProfile(string code, string redirectUrl)
        {
            var api = CreateAPI();

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

            var user = new Sparkle.LinkedInNET.UserAuthorization(userToken.AccessToken);

            var fieldSelector = FieldSelector.For <Person>().WithFirstName().WithLastName().WithEmailAddress();

            var profile = api.Profiles.GetMyProfile(user, null, fieldSelector);

            return(profile);
        }
        private async Task <Person> GetMyProfileAsync(UserAuthorization user)
        {
            try
            {
                string culture         = "en-US";
                var    acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };
                var    fields          = FieldSelector.For <Person>().WithAllFields();
                var    profile         = await api.Profiles.GetMyProfileAsync(user, acceptLanguages, fields);

                return(profile);
            }
            catch (Exception ex)
            {
                errors.Add(ex.ToString());
                return(null);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="code"></param>
        /// <param name="redirectUrl"></param>
        /// <param name="linkedInClientId"></param>
        /// <param name="LinkedInClientSecret"></param>
        /// <returns></returns>
        public async Task <Person> ReadMyProfile(string code, string redirectUrl, string linkedInClientId, string linkedInClientSecret)
        {
            try
            {
                var api           = ConfigLinkedInAPI(linkedInClientId, linkedInClientSecret);
                var userToken     = api.OAuth2.GetAccessToken(code, redirectUrl);
                var user          = new Sparkle.LinkedInNET.UserAuthorization(userToken.AccessToken);
                var fieldSelector = FieldSelector.For <Person>().WithFirstName()
                                    .WithLastName()
                                    .WithEmailAddress()
                                    .WithFormattedName()
                                    .WithEmailAddress()
                                    .WithHeadline()

                                    .WithLocationName()
                                    .WithLocationCountryCode()

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

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

                                    .WithProposalComments()
                                    .WithAssociations()
                                    .WithInterests()
                                    .WithLanguageId()
                                    .WithLanguageName()
                                    .WithLanguageProficiency()
                                    .WithCertifications()
                                    .WithEducations()
                                    .WithFullVolunteer()
                                    .WithPatents();
                var profile = await api.Profiles.GetMyProfileAsync(user, null, fieldSelector);

                return(profile);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 8
0
        public ActionResult Connections(string id, string culture = "en-US", int start = 0, int count = 10, int?days = null)
        {
            var token = this.data.GetAccessToken();

            this.ViewBag.Token = token;
            var user            = new UserAuthorization(token);
            var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };

            {
                var fields = FieldSelector.For <Person>()
                             .WithFirstName().WithLastName().WithHeadline()
                             .WithPictureUrl();
                this.ViewBag.Profile = this.api.Profiles.GetMyProfile(user, acceptLanguages, fields);
            }

            Connections model;

            {
                var fields = FieldSelector.For <Connections>()
                             .WithDistance().WithPictureUrl()
                             .WithSummary().WithLocationName().WithLocationCountryCode()
                             .WithIndustry().WithId()
                             .WithPublicProfileUrl()
                             .WithFirstName().WithLastName().WithHeadline();

                if (days == null)
                {
                    model = this.api.Profiles.GetConnectionsByProfileId(user, id, start, count, fields);
                }
                else
                {
                    var date          = DateTime.UtcNow.AddDays(-days.Value);
                    var modifiedSince = date.ToUnixTime();
                    model = this.api.Profiles.GetNewConnectionsByProfileId(user, id, start, count, modifiedSince, fields);
                }
            }

            this.ViewBag.id    = id;
            this.ViewBag.start = start;
            this.ViewBag.days  = days;
            this.ViewBag.count = count;
            this.ViewBag.days  = days;

            return(this.View(model));
        }
Ejemplo n.º 9
0
        public async Task <ActionResult> Index(string culture = "en-US")
        {
            var token = this.data.GetAccessToken();

            this.ViewBag.Token = token;
            var user            = new UserAuthorization(token);
            var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };

            {
                var fields = FieldSelector.For <Person>()
                             .WithPositions().WithId().WithPictureUrl()
                             .WithFirstName().WithLastName().WithHeadline();
                ////.WithConnections();
                this.ViewData["MyProfile"] = this.api.Profiles.GetMyProfile(user, acceptLanguages, fields);
                this.ViewBag.Profile       = this.ViewData["MyProfile"];

                {
                    var pictures = await this.api.Profiles.GetOriginalProfilePictureAsync(user);

                    pictures = pictures ?? new PictureUrls()
                    {
                        PictureUrl = new List <string>(),
                    };

                    {
                        var more = await this.api.Profiles.GetProfilePictureAsync(user, 120, 120);

                        if (more != null && more.PictureUrl != null)
                        {
                            pictures.PictureUrl.AddRange(more.PictureUrl);
                        }
                    }

                    this.ViewBag.Pictures = this.ViewData["ProfilePictures"] = pictures;
                }
            }

            ////{
            ////    var companies = this.api.Companies.GetList(user);
            ////    this.ViewBag.Companies = companies;
            ////}

            return(this.View());
        }
Ejemplo n.º 10
0
        public ActionResult FullProfile(string id, string culture = "en-US")
        {
            var token = this.data.GetAccessToken();

            this.ViewBag.Token = token;
            var user = new UserAuthorization(token);

            Person profile = null;
            var    watch   = new Stopwatch();

            watch.Start();
            try
            {
                ////var profile = this.api.Profiles.GetMyProfile(user);
                var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };
                var fields          = FieldSelector.For <Person>()
                                      .WithAllFields();
                profile = this.api.Profiles.GetMyProfileAsync(user, acceptLanguages, fields).Result;

                this.ViewBag.Profile = profile;
            }
            catch (LinkedInApiException ex)
            {
                this.ViewBag.ProfileError = ex.ToString();
                this.ViewBag.RawResponse  = ex.Data["ResponseText"];
            }
            catch (LinkedInNetException ex)
            {
                this.ViewBag.ProfileError = ex.ToString();
                this.ViewBag.RawResponse  = ex.Data["ResponseText"];
            }
            catch (Exception ex)
            {
                this.ViewBag.ProfileError = ex.ToString();
            }

            watch.Stop();
            this.ViewBag.ProfileDuration = watch.Elapsed;

            return(this.View(profile));
        }
Ejemplo n.º 11
0
        public async Task <ActionResult> Company(int id, string culture = "en-US", int start = 0, int count = 10, string eventType = null)
        {
            var token = this.data.GetAccessToken();

            this.ViewBag.Token = token;
            var user            = new UserAuthorization(token);
            var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };

            Company company;

            {
                var fields = FieldSelector.For <Company>()
                             .WithAllFields();
                company = await this.api.Companies.GetByIdAsync(user, id.ToString(), fields);
            }

            {
                var fields = FieldSelector.For <CompanyUpdates>();
                var shares = this.api.Companies.GetShares(user, id, start, count, eventType);
                this.ViewBag.Shares = shares;
            }

            return(this.View(company));
        }
Ejemplo n.º 12
0
        public async Task <ActionResult> Index(string culture = "en-US")
        {
            // step 1: configuration
            this.ViewBag.Configuration = this.apiConfig;

            // step 2: authorize url
            var scope       = AuthorizationScope.ReadEmailAddress | AuthorizationScope.ReadWriteCompanyPage;
            var state       = Guid.NewGuid().ToString();
            var redirectUrl = this.Request.Compose() + this.Url.Action("OAuth2");

            this.ViewBag.LocalRedirectUrl = redirectUrl;
            if (this.apiConfig != null && !string.IsNullOrEmpty(this.apiConfig.ApiKey))
            {
                var authorizeUrl = this.api.OAuth2.GetAuthorizationUrl(scope, state, redirectUrl);
                this.ViewBag.Url = authorizeUrl;
            }
            else
            {
                this.ViewBag.Url = null;
            }

            // step 3
            if (this.data.HasAccessToken)
            {
                var token = this.data.GetAccessToken();
                this.ViewBag.Token = token;
                var user = new UserAuthorization(token);

                var watch = new Stopwatch();
                watch.Start();
                try
                {
                    ////var profile = this.api.Profiles.GetMyProfile(user);
                    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 = await this.api.Profiles.GetMyProfileAsync(user, acceptLanguages, fields);

                    var originalPicture = await this.api.Profiles.GetOriginalProfilePictureAsync(user);

                    this.ViewBag.Picture = originalPicture;

                    this.ViewBag.Profile = profile;
                }
                catch (LinkedInApiException ex)
                {
                    this.ViewBag.ProfileError = ex.ToString();
                }
                catch (Exception ex)
                {
                    this.ViewBag.ProfileError = ex.ToString();
                }

                watch.Stop();
                this.ViewBag.ProfileDuration = watch.Elapsed;
            }

            return(this.View());
        }
Ejemplo n.º 13
0
        public ActionResult FullProfile(string id, string culture = "en-US")
        {
            var token = this.data.GetAccessToken();

            this.ViewBag.Token = token;
            var user = new UserAuthorization(token);

            Person profile = null;
            var    watch   = new Stopwatch();

            watch.Start();
            try
            {
                ////var profile = this.api.Profiles.GetMyProfile(user);
                var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };
                var fields          = FieldSelector.For <Person>()
                                      .WithFirstName().WithFormattedName().WithLastName()
                                      .WithHeadline()
                                      .WithId()
                                      .WithEmailAddress()

                                                          //.WithLocation()
                                      .WithLocationName() // subfields issue
                                                          //.WithLocationCountryCode() // subfields issue

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

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

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

                                      .WithDateOfBirth()
                                      .WithPhoneNumbers()
                                      .WithImAccounts()
                                      .WithPrimaryTwitterAccount()
                                      .WithTwitterAccounts()
                                      .WithAllFields()
                ;
                profile = this.api.Profiles.GetProfileById(user, id, acceptLanguages, fields);

                this.ViewBag.Profile = profile;
            }
            catch (LinkedInApiException ex)
            {
                this.ViewBag.ProfileError = ex.ToString();
                this.ViewBag.RawResponse  = ex.Data["ResponseText"];
            }
            catch (LinkedInNetException ex)
            {
                this.ViewBag.ProfileError = ex.ToString();
                this.ViewBag.RawResponse  = ex.Data["ResponseText"];
            }
            catch (Exception ex)
            {
                this.ViewBag.ProfileError = ex.ToString();
            }

            watch.Stop();
            this.ViewBag.ProfileDuration = watch.Elapsed;

            return(this.View(profile));
        }
Ejemplo n.º 14
0
        public async Task <ActionResult> Company(int id, string culture = "en-US", int start = 0, int count = 10, string eventType = null)
        {
            this.ViewBag.Id        = id;
            this.ViewBag.EventType = eventType;

            var token = this.data.GetAccessToken();

            this.ViewBag.Token = token;
            var user            = new UserAuthorization(token);
            var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };

            Exception error = null;
            Company   company;

            {
                var fields = FieldSelector.For <Company>()
                             .WithAllFields();
                try
                {
                    company = await this.api.Companies.GetByIdAsync(user, id.ToString(), fields);
                }
                catch (LinkedInApiException ex)
                {
                    if (ex.StatusCode == 403)
                    {
                        company      = new Company();
                        company.Id   = id;
                        company.Name = "Company " + id + " - Permission error";
                        error        = ex;
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            this.ViewBag.SharesStart = start;
            this.ViewBag.SharesCount = count;
            this.ViewBag.SharesTotal = 0;
            if (error != null)
            {
                var fields = FieldSelector.For <CompanyUpdates>();
                Companies.CompanyUpdates shares;
                try
                {
                    if (string.IsNullOrEmpty(eventType))
                    {
                        shares = await this.api.Companies.GetSharesAsync(user, id, start, count);
                    }
                    else
                    {
                        shares = await this.api.Companies.GetSharesAsync(user, id, start, count, eventType);
                    }

                    this.ViewBag.SharesTotal = shares.Total;
                    this.ViewBag.Shares      = shares;
                }
                catch (LinkedInApiException ex)
                {
                    if (ex.StatusCode == 403)
                    {
                        error = ex;
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            this.ViewBag.Error = error;

            return(this.View(company));
        }
Ejemplo n.º 15
0
        public async Task <ActionResult> OAuth2(string code, string state, string error, string error_description)
        {
            //2 Step:After logging in, linkedin will redirect back to our site, to the url that whe mentioned in reurn_uri, with Authorize Code or error
            Person          profile         = null;
            LinkedInProfile linkedInProfile = new LinkedInProfile();

            if (!string.IsNullOrEmpty(error) | !string.IsNullOrEmpty(error_description))
            {
                this.ViewBag.Error            = error;
                this.ViewBag.ErrorDescription = error_description;
                return(View());
            }
            else
            {
                //3rd step: If no errors, Get the AccessToken from the AuthorizeCode that linkedin sent back to us
                try
                {
                    // get the APIs client to get the accesstoken
                    LinkedInApi api       = new LinkedInApi(config);
                    var         userToken = await api.OAuth2.GetAccessTokenAsync(code, redirect_uri);

                    //4th step: Use this access token to get the loggedin Member details
                    if (userToken != null && !string.IsNullOrEmpty(userToken.AccessToken))
                    {
                        //1-way to get member profile details: Conventional way  // Not giving all the values for the specified scopes
                        //var Profileclient = new RestClient("https://api.linkedin.com/v2/me?projection=(id,firstName,lastName,title,position,profilePicture,displayImage,profilePicture(displayImage~:playableStreams))") { };
                        //var ProfileAuthRequest = new RestRequest("", Method.GET) { };
                        //ProfileAuthRequest.AddHeader("Authorization", "Bearer " + userToken.AccessToken);
                        //var Profileresponse = Profileclient.Execute(ProfileAuthRequest);

                        //2-way to get member profile details: Through  Sparkle.LinkedInNET plugin
                        var      user        = new UserAuthorization(userToken.AccessToken);
                        string[] acceptlangs = { "en-US" };// need to pass the accepting languages
                        profile = api.Profiles.GetMyProfile(user, acceptlangs, FieldSelector.For <Person>().WithEmailAddress().WithId().WithPictureUrl().WithPositionsTitle().WithSummary().WithFirstName().WithLastName().WithMaidenName().WithPhoneNumbers().WithPublicProfileUrl());


                        //5th step: After getting the profile details, map to our own model
                        if (profile != null)
                        {
                            //Map return values to our own model
                            linkedInProfile.Firstname        = profile.Firstname;
                            linkedInProfile.Lastname         = profile.Lastname;
                            linkedInProfile.MaidenName       = profile.MaidenName;
                            linkedInProfile.EmailAddress     = profile.EmailAddress;
                            linkedInProfile.PictureUrl       = profile.PictureUrl;
                            linkedInProfile.PublicProfileUrl = profile.PublicProfileUrl;
                            linkedInProfile.Summary          = profile.Summary;
                            if (profile.Positions != null)
                            {
                                PersonPosition personpos = profile.Positions.Position.FirstOrDefault() != null?profile.Positions.Position.SingleOrDefault() : new PersonPosition();

                                linkedInProfile.PositionTitle = personpos.Title ?? string.Empty;
                            }
                            if (profile.PhoneNumbers != null)
                            {
                                PhoneNumber phonenum = profile.PhoneNumbers.PhoneNumber.Count > 0 ? profile.PhoneNumbers.PhoneNumber.SingleOrDefault() : new PhoneNumber();
                                linkedInProfile.PhoneNumber = phonenum.Number ?? string.Empty;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                    // throw new HttpRequestException("Request to linkedin Service failed.");
                }
            }

            return(View(linkedInProfile));
        }
Ejemplo n.º 16
0
        public async Task <ActionResult> Index(string culture = "en-US")
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            // step 1: configuration
            this.ViewBag.Configuration = this.apiConfig;

            // step 2: authorize url
            var scope       = AuthorizationScope.ReadEmailAddress | AuthorizationScope.ReadWriteCompanyPage | AuthorizationScope.WriteShare;
            var state       = Guid.NewGuid().ToString();
            var redirectUrl = this.Request.Compose() + this.Url.Action("OAuth2");

            this.ViewBag.LocalRedirectUrl = redirectUrl;
            if (this.apiConfig != null && !string.IsNullOrEmpty(this.apiConfig.ApiKey))
            {
                var authorizeUrl = this.api.OAuth2.GetAuthorizationUrl(scope, state, redirectUrl);
                this.ViewBag.Url = authorizeUrl;
            }
            else
            {
                this.ViewBag.Url = null;
            }

            var accessToken = "";

            this.data.SaveAccessToken(accessToken);


            // step 3
            if (this.data.HasAccessToken)
            {
                var token = this.data.GetAccessToken();
                this.ViewBag.Token = token;
                var user = new UserAuthorization(token);

                var watch = new Stopwatch();
                watch.Start();
                try
                {
                    ////var profile = this.api.Profiles.GetMyProfile(user);
                    var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };
                    var fields          = FieldSelector.For <Person>()
                                          .WithAllFields();
                    var profile = await this.api.Profiles.GetMyProfileAsync(user, acceptLanguages, fields);


                    // var getVideo = await this.api.Asset.GetAssetAsync(user, "C4D05AQH5Hen4KpIFqA");


                    // var videoData = DownladFromUrlToByte("https://c3labsdevstorage.blob.core.windows.net/7e46a98d-a143-4a4d-8e05-b3f95493cce4/e21b6488-8d6e-43e6-8c88-4ac4438ff8cb/videos/48c2071e-e9b0-43f7-8b8a-01da4d8c04a1.mp4");
                    var videoData1 = DownladFromUrlToByte("https://c3labsdevstorage.blob.core.windows.net/7e46a98d-a143-4a4d-8e05-b3f95493cce4/e21b6488-8d6e-43e6-8c88-4ac4438ff8cb/videos/f57f8bc8-4fc8-44e4-9c5f-40f528f1a295.mp4");

                    // var bigVideo = DownladFromUrlToByte("https://c3labsdevstorage.blob.core.windows.net/edf54915-d374-4074-a8ee-196897a7badd/07569e4a-134f-48ec-96cf-c89dd1234e9b/videos/152d90cb-3501-4673-a5b2-1ff61ecc9d33.mpeg");


                    var aaa = await Video.VideoUpload.UploadVideoAsync(api, user, "urn:li:organization:18568129", videoData1);

                    var bb = "";



                    //// Asset test
                    //var asset = new Asset.RegisterUploadRequest()
                    //{
                    //    RegisterUploadRequestData = new Asset.RegisterUploadRequestData()
                    //    {

                    //        // fileSizeIn bytes
                    //        FileSize = 52429800,
                    //        SupportedUploadMechanism = new List<string>() { "MULTIPART_UPLOAD" },
                    //        // SupportedUploadMechanism = new List<string>() { "SINGLE_REQUEST_UPLOAD" },
                    //        // Owner = "urn:li:person:" + "qhwvZ0K4cr",
                    //        Owner = "urn:li:organization:18568129",
                    //        Recipes = new List<string>() { "urn:li:digitalmediaRecipe:feedshare-video" },
                    //        ServiceRelationships = new List<Asset.ServiceRelationship>()
                    //        {
                    //            new Asset.ServiceRelationship()
                    //            {
                    //                Identifier = "urn:li:userGeneratedContent",
                    //                RelationshipType = "OWNER"
                    //            }
                    //        }
                    //    }
                    //};
                    //var requestAsset = await this.api.Asset.RegisterUploadAsync(user, asset);


                    //var multiPartSend = await Internals.LongVideoUpload.UploadLongVideoPartsAsync(this.api, requestAsset, bigVideo);

                    ////var postAsset = await this.api.Asset.UploadAssetAsync(requestAsset.Value.UploadMechanism.ComLinkedinDigitalmediaUploadingMediaUploadHttpRequest.UploadUrl, new Asset.UploadAssetRequest()
                    ////{
                    ////    RequestHeaders = new Asset.ComLinkedinDigitalmediaUploadingMediaUploadHttpRequest()
                    ////    {
                    ////        Headers = requestAsset.Value.UploadMechanism.ComLinkedinDigitalmediaUploadingMediaUploadHttpRequest.Headers,
                    ////        UploadUrl = requestAsset.Value.UploadMechanism.ComLinkedinDigitalmediaUploadingMediaUploadHttpRequest.UploadUrl,
                    ////    },
                    ////    Data = videoData1
                    ////});

                    //var test = "sss";



                    // video test
                    var ugcPost = new UGCPost.UGCPostData()
                    {
                        // Author = "urn:li:person:" + "qhwvZ0K4cr",
                        // Author = "urn:li:organization:" + "18568129",
                        Author          = "urn:li:organization:18568129",
                        LifecycleState  = "PUBLISHED",
                        SpecificContent = new UGCPost.SpecificContent()
                        {
                            ComLinkedinUgcShareContent = new UGCPost.ComLinkedinUgcShareContent()
                            {
                                UGCMedia = new List <UGCPost.UGCMedia>()
                                {
                                    new UGCPost.UGCMedia()
                                    {
                                        UGCMediaDescription = new UGCPost.UGCText()
                                        {
                                            Text = "test description"
                                        },
                                        Media  = "urn:li:digitalmediaAsset:C4D05AQGYz5sONvv20g",// requestAsset.Value.Asset, // "urn:li:digitalmediaAsset:C4D05AQHwsp8DLpxHiA", // "urn:li:digitalmediaAsset:C5500AQG7r2u00ByWjw",
                                        Status = "READY",
                                        // Thumbnails = new List<string>(),
                                        UGCMediaTitle = new UGCPost.UGCText()
                                        {
                                            Text = "Test Title"
                                        }
                                    }
                                },
                                ShareCommentary = new UGCPost.UGCText()
                                {
                                    Text = "Test Commentary"
                                },
                                ShareMediaCategory = "VIDEO"
                            }
                        },
                        //TargetAudience = new Common.TargetAudience()
                        //{

                        //},
                        Visibility = new UGCPost.UGCPostvisibility()
                        {
                            comLinkedinUgcMemberNetworkVisibility = "PUBLIC"
                        }
                    };

                    var ugcPostResult = await this.api.UGCPost.PostAsync(user, ugcPost);

                    var test2 = "sdfas";



                    //// image test
                    //// var imageData = DownladFromUrlToByte("https://c3labsdevstorage.blob.core.windows.net/7e46a98d-a143-4a4d-8e05-b3f95493cce4/e21b6488-8d6e-43e6-8c88-4ac4438ff8cb/images/83278b25-b809-4458-912b-55b4d6d8b19d.jpg");
                    //var imageData = DownladFromUrlToByte("https://c3labsdevstorage.blob.core.windows.net/7e46a98d-a143-4a4d-8e05-b3f95493cce4/e21b6488-8d6e-43e6-8c88-4ac4438ff8cb/images/b7b12f6e-4eed-4ca1-b937-006b0c2aa93b.jpg");

                    //var postId = this.api.Media.Post(user, new Common.MediaUploadData()
                    //{
                    //    Data = imageData
                    //});

                    //var test = "sdfas";



                    // var profile1 =  this.api.Profiles.GetMyProfile(user, acceptLanguages, fields);


                    //var firstName = profile.FirstName.Localized.First.ToObject<string>();
                    //var firstName1 = profile.FirstName.Localized.First.Last.ToString();
                    //var firstName2 = profile.FirstName.Localized.First.ToObject<string>();

                    //var fieldsOrg = FieldSelector.For<OrganizationalEntityAcls>()
                    //    .WithAllFields();
                    //var userCompanies = this.api.Organizations.GetUserAdminApprOrganizations(user, fieldsOrg);


                    //var statistic = this.api.Shares.GetShareStatistics(user, "18568129", "6386953337324994560");

                    //var orgFollorerStatistic = this.api.Organizations.GetOrgFollowerStatistics(user, "18568129");

                    //var getShares = this.api.Shares.GetShares(user, "urn:li:organization:18568129", 1000, 5, 0);

                    //var postResult = this.api.Shares.Post(user, new Common.PostShare()
                    //{
                    //    Content = new Common.PostShareContent()
                    //    {
                    //        Title = "tttt",
                    //        ContentEntities = new List<Common.PostShareContentEntities>() { new Common.PostShareContentEntities() {
                    //                  //EntityLocation = "https://www.example.com/",
                    //                  //Thumbnails = new List<Common.PostShareContentThumbnails>(){new Common.PostShareContentThumbnails()
                    //                  //{
                    //                  //    ResolvedUrl = "http://wac.2f9ad.chicdn.net/802F9AD/u/joyent.wme/public/wme/assets/ec050984-7b81-11e6-96e0-8905cd656caf.jpg?v=30"
                    //                  //} }
                    //                  Entity = postId.Location
                    //              }
                    //          }
                    //    },
                    //    Distribution = new Common.Distribution()
                    //    {
                    //        LinkedInDistributionTarget = new Common.LinkedInDistributionTarget()
                    //        {
                    //            VisibleToGuest = true
                    //        }
                    //    },
                    //    Subject = "sub",
                    //    Text = new Common.PostShareText()
                    //    {
                    //        Text = "text"
                    //    },
                    //    // Owner = "urn:li:person:" + "123456789"
                    //    Owner = "urn:li:organization:18568129",
                    //}
                    //);

                    // var originalPicture = await this.api.Profiles.GetOriginalProfilePictureAsync(user);
                    // this.ViewBag.Picture = originalPicture;

                    this.ViewBag.Profile = profile;
                }
                catch (LinkedInApiException ex)
                {
                    this.ViewBag.ProfileError = ex.ToString();
                }
                catch (Exception ex)
                {
                    this.ViewBag.ProfileError = ex.ToString();
                }

                watch.Stop();
                this.ViewBag.ProfileDuration = watch.Elapsed;
            }

            return(this.View());
        }