Ejemplo n.º 1
0
 public GoogleService()
 {
     SearchService = new CustomsearchService(new BaseClientService.Initializer
     {
         ApplicationName = ApplicationName,
         ApiKey          = ApiKey
     });
     KnowledgeGraphService = new KgsearchService(new BaseClientService.Initializer
     {
         ApplicationName = ApplicationName,
         ApiKey          = ApiKey
     });
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Searches Knowledge Graph for entities that match the constraints.A list of matched entities will be returned in response, which will be inJSON-LD format and compatible with http://schema.org
        /// Documentation https://developers.google.com/kgsearch/v1/reference/entities/search
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Kgsearch service.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>SearchResponseResponse</returns>
        public static SearchResponse Search(KgsearchService service, EntitiesSearchOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }

                // Building the initial request.
                var request = service.Entities.Search();

                // Applying optional parameters to the request.
                request = (EntitiesResource.SearchRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Entities.Search failed.", ex);
            }
        }
Ejemplo n.º 3
0
 public Function(ILogger <Function> logger, KgsearchService kgService, SlackRequestVerifier verifier) =>
 (_logger, _kgService, _verifier) = (logger, kgService, verifier);