Exemplo n.º 1
0
        public AlchemyResponse GetAlchemyConceptTags(ContentData contentData)
        {
            var html = contentData.Html;

            var response             = new AlchemyResponse();
            var alchemyConfiguration = new Alchemy.ConfigValues();

            using (WebClient client = new WebClient())
            {
                client.Headers["Content-Type"] = "application/x-www-form-urlencoded";

                var uploadRequest = "apikey=" + alchemyConfiguration.ApiKey; // configuration values
                uploadRequest += "&text=" + HttpUtility.UrlEncode(StripHtml(html));
                uploadRequest += "&outputMode=json";
                uploadRequest += "&linkedData=0";

                var jsonResponse = client.UploadString(alchemyConfiguration.BaseUrl + alchemyConfiguration.ConceptsPath, uploadRequest);
                response = JSer.Deserialize <AlchemyResponse>(jsonResponse);
            }

            if (!string.IsNullOrEmpty(response.statusInfo))
            {
                // Error
                return(null);
            }

            return(response);
        }
Exemplo n.º 2
0
        public void TagContent(long ContentID, AlchemyResponse Tags)
        {
            TagData cmsTag = null;

            foreach (var tag in Tags.concepts)
            {
                cmsTag            = new TagData();
                cmsTag.LanguageId = TagCRUD.ContentLanguage;
                cmsTag.Text       = CleanTag(tag.text);
                cmsTag.Type       = TagTypes.All;

                TagCRUD.Add(cmsTag);
                TagCRUD.Tag(cmsTag.Text, ContentID, Ektron.Cms.Common.EkEnumeration.CMSObjectTypes.Content);
            }
        }