Questions regarding Google site search in combination with Google API - asp.net-mvc-4

I am trying to incorporate Google site search into my .NET MVC project and I am very confused about the documentation.
The google XML API reference makes absolutely no reference to any code or classes that can be used for the search. As a result I am retreiving the XML and parsing it manually.
However, I have also come across the Google API as well and I am not sure whether these are connected or two different things and also confused why developers.google.com makes no reference to the existence of code.google.com
So my questions are here in order to put an end to the confusion.
a) Google site search (paid service) is possible to be used with the Google API despite there being no information about that on the developer section of the XML API? Mind you, you don't need an API key for the use of Google site search.
b) Is API an entirely separate entity that requires an API key and therefore not recommended for commercial use alongside Google site search because of API restrictions that otherwise don't exist with the plain paid service?
c) What is best practice when implementing Google site search (which I understand is the paid version of Google custom search) inside a .NET MVC 4 application? To fetch the XML and parse it manually or to consume the request into de serialized objects using the API?
Currently I am doing the former but I keep wondering if I can produce better, more testable code by combining my solution with the API.
I keep finding mixed resources regarding that on the web and I am not sure which way to go.
Thanks

I can't help with the .NET best practices, but can tell something about APIs. There are 2 different APIs for Custom Search (apart from the js widget):
Older, XML API: https://developers.google.com/custom-search/docs/xml_results
Newer, JSON API: https://developers.google.com/custom-search/json-api/v1/overview
I believe the library you mentioned is for the latter.
The API key for paid site search version can be found in the Control Panel google.com/cse.

Use below steps to implement Google custom search engine in ASP.Net MVC
Add controller
public class SearchController : Controller
{
public ActionResult Search(string SearchString)
{
ViewBag.SearchString = SearchString;
ViewBag.Title = "Search";
return View("SearchResult");
}
}
Add form to take user input
<div class="searchControl">
#using (Html.BeginForm("Search", "Search", FormMethod.Get))
{
<div class="input-group">
<input type="text" name="SearchString" class="form-control" placeholder="type something and hit enter">
<span class="input-group-btn">
<input class="btn" type="submit" value="Search!"/>
</span>
</div><!-- /input-group -->
}
</div>
Add Search result page
#{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="container"">
<div class="row">
<div class="col-md-12">
<script>
//put here your Google custom search engine script
</script>
<gcse:search>
</gcse:search>
</div>
</div>
</div>
Here is complete step by step Article to implement Google custom search engine in MVC

Related

Google Recapcha v3: use same key in different forms in the same domain

Quick question: I have on a website 3 different contact forms for different languages. All 3 forms point to the same PHP script which processes the data and sends it to us via email.
Can I use the same Google Recaptcha v3 key for the 3 forms, or do I have to create different ones?
Also, this is an exceedingly silly question, but just in case: I have seen some sample code where they added a hidden field in the form for the recaptcha response:
<input type="hidden" name="recaptcha_response" id="recaptchaResponse">
From what I understand in the docs, this isn't needed anymore in V3. Instead, you can name the button "g-recaptcha" and capture in the PHP form the $_POST["g-recaptcha"] variable:
<button class="g-recaptcha" data-sitekey="mykey" data-callback='onSubmit' data-action='submit'>
Can anyone confirm that this is the case?
Thanks.

Eventbrite API list events 403

I'm trying to fetch events base on time from Eventbrite API with the following command from the docs
curl -X GET https://www.eventbriteapi.com/v3/events/search?date_modified.range_start=2018-01-01T00:00:01Z -H 'Authorization: Bearer MY_API_TOKEN'
However, it returns me 403 with the following HTML in response body:
<html lang="en">
<head>
<title>Whoops!</title>
</head>
<body>
<div id="whoops_wrapper">
<img id="logo" src="https://cdn.evbstatic.com/s3-s3/static/images/django/logos/eb_home_stroke-trans.png" width="154" />
<h1>
This page is <br />currently unavailable.
</h1>
<p>
The Team is currently working to return you to the service as quickly as possible.<br />
If you need to reach us immediately, please <a href='https://www.eventbrite.com/support/contact-us'>contact us</a>.
</p>
<p>
We'll keep you updated on <a href='https://www.twitter.com/eventbrite'>Twitter</a>.<br />
<a href='https://www.eventbritestatus.com/'>Eventbrite Status Page</a>
</p>
<p><font size="-2">Response code: 403</font></p>
</div>
</body>
</html>
It use to work fine before and now it like this for a couple days. I tried to create a new API Token with no success. Calling other endpoints from the API seams working fine. I also didn't hit the rate limit. Any ideas what it could be or things to try?
According to the linked Google Group Thread
Thank you for your patience. We recently made some changes to our APIs in an effort to improve platform functionality and performance. Some of these adjustments necessitated the unforeseen and immediate deprecation of one of our public Event Search APIs events/search endpoint.
Since this change was made, the team has been working hard on potential solutions for providing access to our event feed for API users that are not part of our official distribution partner program. We wanted to reach out to acknowledge the frustration you’re feeling and let you know that we will update you with more details over the coming week as we determine the viability of a potential replacement solution.
Regards,
Eventbrite.
So it looks like they've discontinued search from the public API.
Update: The Search API has been discontinued as of December 12 here
Just came across official Google Support group. Seams like internal Eventbrite issue. :(

Vb.net : Submitting multpart/related form to cloud via web service call

I am a newbie to VB.net and web services in general.
I am working on designing a feature that ,
i.Accepts a document (Content-type : multipart/related) from outside.(Parameterized input to my code maybe ?)
ii.Does a call on a web service to submit that to a cloud server (eg. maybe amazon , maybe something else)
I want to know where to start with this,
i want to create a small vb.net project first that accepts as input some (multipart/related form based document) and does a call(post) on a web service that sends out that data to the cloud.
How are these multipart documents posted ?
Edit :
The web service API i am working on will have a WebMethod that will accept a file (xml/json) as input and create a multipart/related document and then post it to a web service. i did see posts here that work with creating multipart/form-data but am not sure if the way to create a multpart/related document will be the same because multipart/related documents work with compound documents.
Ref: Upload files with HTTPWebrequest (multipart/form-data)
From this question, your HTML might look something like this:
<form id="uploadbanner" enctype="multipart/form-data" method="post" action="#">
<input id="fileupload" name="myfile" type="file" />
<input type="submit" value="submit" id="submit" />
</form>
From here, this server side code may get you started:
Dim savedFile As String
savedFile = Path.GetFileName(Me.fileUpload.PostedFile.FileName)
Me.fileUpload.PostedFile.SaveAs(Server.MapPath("cvs\"))
"Submit[ting] to a cloud server" is going to be completely dependent on which service you use. You'll have to choose one first, and I'd be willing to bet they have some kind of API with examples to help you use their service. In addition, there are probably great examples here on StackOverflow to get you going. The search function can be a great help when you're ready.

How to post form data to Apache Sling using a Java servlet

I am trying to POST the data from a html page and post it to a sling using a java servlet..
Note: My webapp is running in tomcat(port 8080), and my sling runs in a different port(8999).
my html is a very simple form with just one input box
<form action = "/data" method="post">
<input type="text" name="input" />
<input type="submit" name="Submit" />
</form>
and in the servlet i have received the data in the input box.
Sting name = request.getParameter("input")
I also went through to the documentation in the official docs, but didnt find anything helpful regarding this.
Any code that help me understand the post part will be helpful.
Reworked answer taking into account your question edits: it looks like what you want is to make POST requests from another Java application to Sling.
If that's correct you can use the httpclient library which is discussed in another question here, see How do I make a WebDav call using HttpClient?

Best practices for adding semantics to a website

I am a bit confused about the semantics of websites. I understand that every URI should represent a ressource. I assume that all information provided by RDFa inside a webpage describes the ressource represented by the URI of that webpage. My question is: What are best practices for providing semantic data for subpages of a website.
In my case I want to create a website for a theater group called magma using RDFa with schema.org and opengraph vocabularies. Let's say I have the welcome page (http://magma.com/), a contact page (http://magma.com/contact/) and pages for individual plays (http://magma.com/play/<playid>/).
Now I would think that both the welcome page and the contact page represent the same ressource (magma) while providing different information about that ressource. The play pages however represent plays that only happen to be performed by magma. Or is it better to say that the play pages also represent magma but providing information about plays which will be performed by that group? The third option I stumbled upon is http://schema.org/WebPage. Especially subtypes like ContactPage seems to be relevant.
When it comes to implementation, where do I put the RDFa?
And finally: How will my choice change the way the website is treated by 3rd parties (google, facebook, ...)?
I realize this question is a bit blurry. To make it more concrete I will add an example that you might critizise:
<html vocab="http://schema.org/" typeof="TheaterGroup">
<head>
<meta charset="UTF-8"/>
<title>Magma - Romeo and Juliet</title>
<!-- magma sematics from a template file -->
<meta property="name" content="Magma"/>
<meta property="logo" content="/static/logo.png"/>
<link rel="home" property="url" content="http://magma.com/"/>
</head>
<body>
<h1>Romeo and Juliet</h1>
<!-- semantics of the play -->
<div typeof="CreativeWork" name="Romeo and Juliet">
...
</div>
<h2>Shows</h2>
<!-- samantics of magma events -->
<ul property="events">
<li typeof="Event"><time property="startDate">...</time></li>
...
</ul>
</body>
</html>
I understand that every URI should represent a ressource. I assume that all information provided by RDFa inside a webpage describes the ressource represented by the URI of that webpage.
Well, a HTTP URI could identify the page itself OR the thing the page is about. You can't tell if an URI identifies the page or the thing by simply looking at it.
Example (in Turtle syntax):
<http://en.wikipedia.org/wiki/The_Lord_of_the_Rings> ex:author "John Doe"
This could mean that the HTML page with the URI http://en.wikipedia.org/wiki/The_Lord_of_the_Rings is authored by "John Doe". Or it could mean that the thing described by that HTML page (→ the novel) is authored by "John Doe". Of course this is an important difference.
There are various ways to differentiate what an URI represents, and there is some dispute about it. The discussion around this is known as httpRange-14 issue. See for example the Wikipedia article Web resource.
One way is using hash URIs (see also this answer). Example: http://magma.com/play/42 could identify the page about the play, http://magma.com/play/42#play could identify the play.
Another way is using HTTP status code 303. The code 200 gives the representation of the page about the thing, the code 303 See Other gives an additional URI identifying the thing. This method is used by DBpedia:
http://dbpedia.org/resource/The_Lord_of_the_Rings represents the novel
http://dbpedia.org/page/The_Lord_of_the_Rings represents the page about the novel
(resp. http://dbpedia.org/data/The_Lord_of_the_Rings for machines)
See Choosing between 303 and Hash.
Now, when using RDFa, you can make statements about both, the page itself and the thing represented by the page. Just use the corresponding URI as subject (e.g., by using the resource attribute).
So let's say http://magma.com/#magma represents the theater group. Now you could use this URI on every page (/contact, /play/, …) to make statements about the group resp. to refer to the group.
<div resource="http://magma.com/#magma">
<span property="ex:name">Magma</span>
</div>
<div resource="http://magma.com/">
<span property="ex:name">Website of Magma</span>
</div>
I suggest that you first look at the schema.org straightforward documentation. This vocabulary is very comprehensive for your concerns and supported by the major search engines.
Here is a snippet example for you to get started, you can include this straight in an HTML page. When you speak about the performance of the play on a page you could use:
<div itemscope itemtype="http://schema.org/TheaterEvent">
<h1 itemprop="name">Romeo and Juliet</h1>
<span itemprop="location">Council Bluffs, IA, US</span>
<meta itemprop="startDate" content="2011-05-23">May 23
Buy tickets
</div>
On your contact page you could include:
<div itemscope itemtype="http://schema.org/TheaterGroup">
<span itemprop="name">Magma</span>
Tel:<span itemprop="telephone">( 33 1) 42 68 53 00 </span>
</div>