Can I use a friendly URL on SearchAction? - url

My current URL for searches is this one:
https://example.com/search/key/seach_word_here
JSON-LD
<script type='application/ld+json'>
[
{
"#context":"http:\/\/schema.org",
"#type":"WebSite",
"#id":"#website",
"url":"https://example.com",
"name":"Example",
"potentialAction":{
"#type":"SearchAction",
"target":"https:https://example.com/search/key/{search_term_string}",
"query-input":"required name=search_term_string"
}
},
{
"#context":"http:\/\/schema.org",
"#type":"Organization",
"url": "https://example.com",
"name": "Example",
"logo":"https://example.com/img/logo.png",
"#id":"#organization",
"sameAs": ["https://www.facebook.com/example"]
}
]
</script>
As you can see I'm using a friendly URL on the target.
I have seen people using a query string on the URL like this:
https://example.com/?search={search_term_string}
I did not see people using a friendly URL on the target. It's not allowed?
And at https://developers.google.com/search/docs/data-types/sitelinks-searchbox it says:
Verify your search engine implementation by copying the WebSite.potentialAction.target URL from your structured data, replacing search_term_string with a test query, and browsing to that URL in a web browser. For example, if your website is example.com, and you want to test the query "kittens", you would browse to https://www.example.com/search/?q={kittens}.
I tested this url https://example.com/search/hey/{search_word_here} and I got a 404 not found, but this URL worked: https://example.com/?p=search&tp=key&word={search_word_here}.
So my question is: Can I use a friendly URL on the target? And the code on my snippet is correct?

Of course you have to use the URL that works.
Google will use the target URL for their Sitelink Searchbox, so that users can search on Google’s SERP and end up on your internal SERP. If you specify a target URL that leads to 404 pages, having this feature makes no sense, and Google would have no interest to enable it for your results.
If that URL happens to be friendly (e.g., without a query component), so be it.

Agree with above solution from #unor, now answering about you code correction
Please check the target url in posted JSON-LD:-
"target":"https:https://example.com/search/key/{search_term_string}",
Remove the double https:
Also in case of JSON-LD: you cannot map name value to /{search_term_string}
A correct way is always like this:-
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "WebSite",
"url": "[website url]",
"potentialAction": {
"#type": "SearchAction",
"target": "[website search url]={search_term}",
"query-input": "required name=search_term"
}
}
</script>
Microdata:-
<div itemscope itemtype="http://schema.org/WebSite">
<meta itemprop="url" content="[website url]"/>
<form itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction">
<meta itemprop="target" content="[website search url]={search_term}"/>
<input itemprop="query-input" type="text" name="search_term">
<input type="submit">
</form>
</div>

Related

oembed - how is the scheme URL published?

Providing discovery of your web page in oembed means adding a link such as
<link rel="alternate" type="application/json+oembed"
href="http://flickr.com/services/oembed?
url=http%3A%2F%2Fflickr.com%2Fphotos%2Fbees%2F2362225867%2F&format=json"
title="Bacon Lollys oEmbed Profile" />
so thats a item URL of
http://flickr.com/photos/bees/2362225867/&format=json
However the URL scheme for this general area in flicker is
http://www.flickr.com/photos/*
and this ends up in the following JSON
https://oembed.com/providers.json
as an entry of
{
"provider_name": "Flickr",
"provider_url": "https://www.flickr.com/",
"endpoints": [
{
"schemes": [
"http://*.flickr.com/photos/*",
"http://flic.kr/p/*",
"https://*.flickr.com/photos/*",
"https://flic.kr/p/*"
],
"url": "https://www.flickr.com/services/oembed/",
"discovery": true
}
]
},
Where is this scheme URL obtained from as I don't see it explicitly declared anywhere?
The provider's JSON is supposed to be maintained through discovery via the original s but they do not contain the scheme URL (with the wildcard *'s).

Having trouble adding schema code into my email build

I am having difficulty adding Schema code into my email build - when I test the email in Gmail nothing is displaying.
I have tried testing my email and am not seeing the Schema information.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<script type="application/ld+json">
[{
"#context": "http://schema.org/",
"#type": "Organization",
// WARNING: Before sending email, either point the logo
// at your own image or delete the logo annotation.
//
// If showing a logo, we recommend using an https URL.
// It's not a requirement today, but may be in the future.
"logo": "http://media.bobsdiscountfurniture.com/7843/Miscellaneous/little -bob-profile.jpg"
},{
"#context": "http://schema.org/",
"#type": "EmailMessage",
// Alternative subject line.
"subjectLine": "It's Two for Tuesday!"
},{
"#context": "http://schema.org/",
"#type": "DiscountOffer",
"description": "Two items - one great price!",
"discountCode": "",
"availabilityStarts": "2019-06-09T06:51:45-07:00",
"availabilityEnds": "2019-06-12T06:51:45-07:00"
},{
// Promotion card with single image.
// We recommend using an https URL.//
// Sample image is 538x138, 3.9 aspect ratio
"#context": "http://schema.org/",
"#type": "PromotionCard",
"image": "https://productimages.mybobs.com/20052909/20052909_hero_wide.pn g"
}]
</script>
</head>
<body>
<p>Email Body</p>
<p>Line 2</p>
</body>
</html>
I am hoping to have my Schema code display in my test email proof so that I can send to Google in order to be authorized to incorporate Schema coding into my emails on a regular basis moving forward.
You can refer to the official documentation regarding Email Markup and do a self test by sending email to yourself. Please also remember that for the content of your sample email, it is highly suggested to use a production setup same with your schema code.

Why does my progressive web app open in a browser when I have fullscreen specified in my app manifest?

When I install my web app to homescreen on Android without a service worker, everything works as expected. I can click my home screen icon and my app launches with a splash screen and then I see my app in fullscreen mode. When I add in the service worker registration code and install to home screen, my app launches in a browser window and seems to ignore my manifest file.
Something to note is that without the service worker my app only has an icon on the homescreen. with the service worker code it becomes fully installed with the "new improved add to home screen" and there is an icon on my home screen as well as in my installed apps panel.
Here is my code:
web-app.html:
<!DOCTYPE html>
<html>
<head>
<title>Web App</title>
<meta name = "viewport" content = "user-scalable=no, width=device-width">
<meta name = "mobile-web-app-capable" content = "yes">
<link href = "manifest.json" rel = "manifest">
<link href = "web-app.css" rel = "stylesheet" type = "text/css">
<link href = "web-app.png" rel = "icon" type = "image/png">
</head>
<body>
<h1>Android Web App!</h1>
<img src = "/web-app.png">
<p>This page can be viewed in any browser, but it can also work in a web app! If you are viewing this page in a full screened webview on your mobile device, you are looking at a fully functional web app! You can use this technology to better connect with your users or create a full screen mobile experience for your HTML5 games!</p>
<script type = "text/javascript">
navigator.serviceWorker.register("web-app-service.js");
</script>
</body>
</html>
manifest.json:
{
"author": "PoP Vlog",
"background_color": "#ffffff",
"description": "Progressive Web App Example with Offline Mode",
"display": "fullscreen",
"icons": [{
"src": "/web-app.png",
"sizes": "192x192",
"type": "image/png"
}],
"lang":"en",
"manifest_version": 2,
"name": "Web App",
"orientation": "portrait",
"scope":"/",
"short_name": "Web App",
"start_url": "/",
"theme_color": "#ffffff",
"version": "0.2"
}
web-app-service.js:
self.addEventListener("install", function(event) {
event.waitUntil(caches.open("web-app").then(function(cache) {
return cache.addAll([ "/", "/web-app.html", "/web-app.css", "/web-app.png"]).then(function() {
self.skipWaiting();
});
}));
});
self.addEventListener("activate", function(event) {
event.waitUntil(self.clients.claim());
});
self.addEventListener("fetch", function(event) {
event.respondWith(caches.match(event.request).then(function(response) {
return response || fetch(event.request);
}));
});
I couldn't find a lot of documentation on this, but clearly the behavior changes when I remove the service worker registration code from my html document. I suspect that the problem lies in my web-app-service.js file.
EDIT: 11/01/2017
When I completely comment out my fetch event listener, my app works as expected, but add to home screen only installs an icon on my home screen. When I add to home screen with the fetch event listener, I get a full install of my web app into my apps panel and my app only opens in a browser window with full url bar and everything. This problem has something to do with adding the fetch capability to my service worker.
EDIT 11/08/2017
I have discovered that I only have this problem on my Node JS HTTPS test server when accessing my web app through a local IP address. The web app works fine when I run it from my Github Pages site. This leads me to believe it is a problem with scope in the app manifest or perhaps my Node server.
In manifest.json change "display": "fullscreen" to "display": "standalone".
It'll launch your app in App like view.
For more info refer https://developer.mozilla.org/en-US/docs/Web/Manifest

How to post event to particular google calendar using feed URL

I am trying to post an event to a particular google calendar.
I am using the following URL to post the event:
https://www.google.com/calendar/feeds/CALENDAR-ID/private/full
Using this I get this error:
<HTML>
<HEAD>
<TITLE>Authorization required</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Authorization required</H1>
<H2>Error 401</H2>
</BODY>
I understand that I need to request authorization to post on the calendar but I would like to post the event in my own calendar.
My questions:
1 - Do I need to use OAuth to post an event in my own calendar ?
2 - If not, is there any special URL (like magic-cookie) to use with a read-write access ?
3 - I have a Google API Key but I don't know if I can use it in this case and how it should be used ?
I am trying to post the event from an iOS application using NSURLConnection. Here is the details:
{
"data": {
"title": "Tennis with Beth",
"details": "Meet for a quick lesson.",
"transparency": "opaque",
"status": "pending",
"location": "Rolling Lawn Courts",
"when": [
{
"start": "2013-08-07T15:00:00.000Z",
"end": "2013-08-07T17:00:00.000Z"
}
]
}
}
Headers:
Content-type: application/json
Thank you for your help, I know there is a lot of similar question over internet but everything I try doesn't work and I don't understand the OAuth things in documentation (as I never used OAuth). Also I can;t find in google documentation the case when you want your users to post in a particular calendar.
I found another post on StackOverflow which deals exactly with what I was looking for. The post explain the method using PHP but the process is still the same for iOS.
Google Calendar API v3 hardcoded credentials

Checking if tweet contains a link to external site

To check if a tweet contains a link to an external site, I'm just checking that the tweet contains 'http:' ? Will this suffice ?
I'm accessing the tweets using the twitter rest API, so I parse the json response which contains the tweets.
You can get all the URLs of a tweet using Twitter Entities. When you make the REST call, make sure you include
&include_entities=true
This will give you a section in the JSON or XML called entities. There will be a child node called urls.
Here's an example of what will be returned.
"text": "Twitter for Mac is now easier and faster, and you can open multiple windows at once http://t.co/0JG5Mcq",
"entities": {
"media": [
],
"urls": [
{
"url": "http://t.co/0JG5Mcq",
"display_url": "blog.twitter.com/2011/05/twitte…",
"expanded_url": "http://blog.twitter.com/2011/05/twitter-for-mac-update.html",
"indices": [
84,
103
]
}
],
"user_mentions": [
],
"hashtags": [
]
}
So, look for entities -> urls to see if a tweet contains a link to an external site.
How do you access the tweets? By scraping the twitter site, or through some API? If you use an API, which one, etc. It looks to me like the js-tweet-text section of the source is always formatted to give a link with http://, but it might not be guaranteed. Why don't you just look for href instead?
Example:
<p class="js-tweet-text">
Blabla tweet text... <a data-expanded-url="http://bit.ly/somelink"
class="twitter-timeline-link" href="http://t.co/stuff"
rel="nofollow" class="twitter-timeline-link">bit.ly/somelink
</a>
</p>
Here, both data-expanded-url and twitter-timeline-link seem to give the actual link, while href redirects you via some twitter filter. But anyway, one thing you can be certain of is that links contain a href.

Resources