Beispiel #1
0
        public string GetProfile(Influencer influencer, UserInfluencerAuth userInfluencerAuthKey)
        {
            var url = @"https://api.linkedin.com/v1/people/~:(id,first-name,last-name,maiden-name,formatted-name,phonetic-first-name,phonetic-last-name,formatted-phonetic-name,headline,location,industry,num-connections,num-connections-capped,summary,specialties,positions,picture-url,picture-urls::(original),site-standard-profile-request,api-standard-profile-request)?format=json";
            var r   = _handle(url, influencer, userInfluencerAuthKey);

            return(r);
        }
Beispiel #2
0
        public bool StoreAuthToken(UserInfluencerAuth userInfluencer)
        {
            var parameters = new ParmsCollection();

            parameters.AddParm("@userId", SqlDbType.Int, userInfluencer.UserId);
            parameters.AddParm("@influencerId", SqlDbType.Int, userInfluencer.InfluencerId);
            parameters.AddParm("@userName", SqlDbType.NVarChar, userInfluencer.UserName);
            parameters.AddParm("@secret", SqlDbType.NVarChar, userInfluencer.Secret);
            parameters.AddParm("@secret1", SqlDbType.NVarChar, userInfluencer.Secret1);
            parameters.AddParm("@secret2", SqlDbType.NVarChar, userInfluencer.Secret2);
            parameters.AddParm("@secret3", SqlDbType.NVarChar, userInfluencer.Secret3);
            parameters.AddParm("@other1", SqlDbType.NVarChar, userInfluencer.Other1);
            parameters.AddParm("@other2", SqlDbType.NVarChar, userInfluencer.Other2);

            int numOfRec = unitOfWork.GetIdentityDbContext().ExecuteNonQuery("Scores.UpdateAuthToken", parameters);

            if (numOfRec > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
 public override string Handle(Influencer influencer, UserInfluencerAuth userInfluencerAuthKey)
 {
     //var url = @"https://api.linkedin.com/v1/people/~?format=json";
     //var r = _handle(url, influencer, userInfluencerAuthKey);
     //return r;
     return(GetProfile(influencer, userInfluencerAuthKey));
 }
Beispiel #4
0
        public override string Handle(Influencer influencer, UserInfluencerAuth userInfluencerAuthKey)
        {
            var twitter = new Twitter(influencer.ApiKey, influencer.Other1, influencer.Other2, influencer.Other3);

            var response = twitter.GetTweets(userInfluencerAuthKey.UserName, 50);

            return(response);
        }
Beispiel #5
0
        private string _handle(string url, Influencer influencer, UserInfluencerAuth userInfluencerAuthKey)
        {
            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", userInfluencerAuthKey.Secret);
                var response = client.GetAsync(url).Result;

                return(response.Content.ReadAsStringAsync().Result);
            }
        }
Beispiel #6
0
        public override string Handle(Influencer influencer, UserInfluencerAuth userInfluencerAuthKey)
        {
            var url = @"https://www.googleapis.com/customsearch/v1?key=AIzaSyBAUIgRfOlx8e4OcsZm0CojOTbLnwNyYRs&cx=010411868023207416729:pkel_dw1rf8&q=";

            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Clear();

                var response = client.GetAsync(url + WebUtility.UrlEncode(userInfluencerAuthKey.User.FirstName + " " + userInfluencerAuthKey.User.LastName)).Result;

                return(response.Content.ReadAsStringAsync().Result);
            }
        }
Beispiel #7
0
        public override string Handle(Influencer influencer, UserInfluencerAuth userInfluencerAuthKey)
        {
            var baseUrl     = @"https://graph.facebook.com/";
            var accessToken = "EAAH7RGc2T5QBAKnGzM2XJGOWLcN3o9v4hCN5WZBZA0DjTCrrZBgHR0BgNozl0A1Vz8WJJrFh2NUFiTdpbuBxS4IDJT7GsYFxEeQ1RGUxoNUmhBKULQqpPa11jfWZA6sLwIneCVQwEO54JEnQeEYaCa1d7z4ZCVXtc1GUyhu8TB9QZAr18jHt7DzLZBlZBlkDzFgkBerX1XALPgZDZD";
            var url         = $"{baseUrl}{influencer.Other2}/me?access_token={accessToken}";

            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Clear();
                var response = client.GetAsync(url).Result;

                return(response.Content.ReadAsStringAsync().Result);
            }
        }
Beispiel #8
0
        public async Task <bool> StoreAuthToken(string authCode, ConnectorType connectorType, int LoggedInUserId)
        {
            Influencer influencer = authDataAccess.GetInfluncerAuthInfo(connectorType);
            var        handler    = handlerContainer.GetHandler(connectorType);

            var authTokenDetails = await handler.GetAuthToken(influencer, authCode);

            if (!string.IsNullOrEmpty(authTokenDetails.authToken))
            {
                UserInfluencerAuth userInfluencer = new UserInfluencerAuth()
                {
                    UserId       = LoggedInUserId,
                    InfluencerId = connectorType,
                    Secret       = authTokenDetails.authToken,
                    Other1       = authTokenDetails.expiresIn.ToString()
                };
                bool isSuccess = authDataAccess.StoreAuthToken(userInfluencer);
                return(isSuccess);
            }
            return(false);
        }
Beispiel #9
0
 public virtual string Handle(Influencer influencer, UserInfluencerAuth userInfluencerAuthKey)
 {
     return(string.Empty);
 }