Used to hold the OAuth parameters that are stored in the database
Ejemplo n.º 1
0
        private IEnumerable <IRecord> ExecuteBusinessProfileSearch(AuthenticationData auth, IDictionary <string, object> runtimeParams)
        {
            // we still call the parameter "LinkedInUser" so we can use the same client-side code as with the user profile mashup
            if (runtimeParams.ContainsKey("LinkedInUser"))
            {
                LinkedInUser = (String)runtimeParams["LinkedInUser"];
            }
            if (String.IsNullOrEmpty(LinkedInUser))
            {
                throw new Exception("This method requires a LinkedInUser parameter");
            }

            String url = String.Format(URL_BUSINESS_PROFILE_API, LinkedInUser);

            url = AddAuthentication(url, auth);
            WebClient client = GetWebClient();
            String    data   = Encoding.UTF8.GetString(client.DownloadData(url));
            XDocument xml    = XDocument.Parse(data);

            foreach (XElement personNode in xml.Descendants("company"))
            {
                yield return(RecordBase.CreateRecord(new LinkedinCompany(personNode)));
            }
        }
Ejemplo n.º 2
0
 private IEnumerable<IRecord> ExecuteSocialSearch(AuthenticationData auth, IDictionary<string, object> runtimeParams)
 {
     WebClient client = GetWebClient();
     String url = URL_NETWORK_UPDATES;
     if (runtimeParams.ContainsKey("LinkedInUser") || !String.IsNullOrEmpty(LinkedInUser))
     {
         object specifiedMemberId;
         if (!runtimeParams.TryGetValue("LinkedInUser", out specifiedMemberId))
             specifiedMemberId = LinkedInUser;
         url = String.Format(URL_NETWORK_UPDATE_BYMEMBER, specifiedMemberId);
     }
     url = AddAuthentication(url, auth);
     if (MaximumResults != null)
         url += String.Format("&count={0}", MaximumResults);
     String data = Encoding.UTF8.GetString(client.DownloadData(url));
     XDocument xml = XDocument.Parse(data);
     foreach (XElement update in xml.Element("updates").Elements("update"))
     {
         IRecord result = ParseUpdateNode(update);
         if (result != null)
             yield return result;
     }
 }
Ejemplo n.º 3
0
 private IEnumerable<IRecord> ExecuteProfileSearch(AuthenticationData auth, IDictionary<string, object> runtimeParams)
 {
     if (runtimeParams.ContainsKey("LinkedInUser"))
     {
         LinkedInUser = (String)runtimeParams["LinkedInUser"];
     }
     if (String.IsNullOrEmpty(LinkedInUser))
     {
         throw new Exception("This method requires a LinkedInUser parameter");
     }
     String url = String.Format(URL_PROFILE_API, LinkedInUser);
     url = AddAuthentication(url, auth);
     WebClient client = GetWebClient();
     String data = Encoding.UTF8.GetString(client.DownloadData(url));
     XDocument xml = XDocument.Parse(data);
     foreach (XElement personNode in xml.Descendants("person"))
     {
         yield return RecordBase.CreateRecord(new LinkedinPerson(personNode));
     }
 }
Ejemplo n.º 4
0
 private IEnumerable<IRecord> ExecutePeopleSearch(AuthenticationData auth, IDictionary<string, object> runtimeParams)
 {
     WebClient client = GetWebClient();
     if (runtimeParams.ContainsKey("Search"))
         Search = (String)runtimeParams["Search"];
     if(String.IsNullOrEmpty(Search))
         throw new Exception("This method requires a Search parameter");
     String url = String.Format(URL_PEOPLE_SEARCH, HttpUtility.UrlEncode(Search));
     url = AddAuthentication(url, auth);
     if (MaximumResults != null)
         url += String.Format("&count={0}", MaximumResults);
     String data = Encoding.UTF8.GetString(client.DownloadData(url));
     XDocument xml = XDocument.Parse(data);
     foreach(XElement personNode in xml.Descendants("person")){
         yield return RecordBase.CreateRecord(new LinkedinPerson(personNode));
     }
 }
Ejemplo n.º 5
0
        private IEnumerable<IRecord> ExecuteCompanySharesSearch(AuthenticationData auth, IDictionary<string, object> runtimeParams)
        {
            WebClient client = GetWebClient();
            // we still call the parameter "LinkedInUser" so we can use the same client-side code as with the user profile mashup
            if (runtimeParams.ContainsKey("LinkedInUser"))
            {
                LinkedInUser = (String)runtimeParams["LinkedInUser"];
            }
            if (String.IsNullOrEmpty(LinkedInUser))
            {
                throw new Exception("This method requires a LinkedInUser parameter");
            }

            // fetch the profile first, because it is used to decorate the returned updates
            IRecord profileRecord = ExecuteBusinessProfileSearch(auth, runtimeParams).FirstOrDefault();

            String url = String.Format(URL_COMPANY_SHARES_API, HttpUtility.UrlEncode(LinkedInUser));
            url = AddAuthentication(url, auth);
            url += String.Format("&count={0}", MaximumResults ?? LINKEDIN_DEFAULT_MAXRESULTS);
            String data = Encoding.UTF8.GetString(client.DownloadData(url));
            XDocument xml = XDocument.Parse(data);
            foreach (XElement updateNode in xml.Descendants("update"))
            {
                LinkedinCompanyShare rec = LinkedinCompanyShare.MakeRecord(updateNode, profileRecord);
                if (rec != null)
                {
                    rec.Icon = "LinkedIn_Logo16px.png";
                    yield return RecordBase.CreateRecord(rec);
                }
            }
        }
Ejemplo n.º 6
0
 private string AddAuthentication(string url, AuthenticationData auth)
 {
     if (url.Contains("?"))
         url += "&";
     else
         url += "?";
     url += "oauth2_access_token=" + HttpUtility.UrlEncode(auth.Token);
     return url;
 }