oembed - how is the scheme URL published? - oembed

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).

Related

How to get OneNote Notebook/Section/Page Id from Teams Tab

I have embedded a OneNote notebook into a Microsoft Teams Tab. I am trying to get the Notebook Id using Graphi API
I can get the tab id from channels/{{ChannelId}}/messages/delta end point.
Using tabId, I can get tab details from channels/{{ChannelId}}/tabs/{{tabid}} end point.
Tab details end point gives configuration details that has contentUrl and websiteURL.
{
"id": "tabId",
"displayName": "My Contoso Tab - updated",
"configuration": {
"entityId": "2DCA2E6C7A10415CAF6B8AB6661B3154",
"contentUrl": "",
"websiteUrl": "",
"removeUrl": ""
},
"teamsApp": {
"id": "0d820ecd-def2-4297-adad-78056cde7c78",
"externalId": null,
"displayName": "Contoso",
"distributionMethod": "store"
},
"sortOrderIndex": "20",
"webUrl": ""
}
How can I get notebook Id or Section Id or Page Id that is embedded into the tab?
Formally the OneNote tab explicitly has no public documentation regarding its configuration as per :
https://learn.microsoft.com/en-us/graph/teams-configuring-builtin-tabs#onenote-tabs.
You can indeed try to reverse engineer the content or web URLs, and you may very well succeed today.
But you need to understand , and accept responsibility and the associated integration testing potential downtime as that URL format can/will change with no notification whatsoever.
If you can accept that risk & responsibility, using the oneNoteWebUrl= QSP from the contentUrl json node seems to be a decent key.
"configuration": {
"entityId": "00727f3d-df18-43ac-8cc9-698774312f5e",
"contentUrl": "https://www.onenote.com/teams/TabContent?notebookSource=Pick&notebookSelfUrl=https%3A%2F%2Fwww.onenote.com%2Fapi%2Fv1.0%2FmyOrganization%2Fgroups%0076777f1c-3e3d-44ad-8206-53ba08a44cec%2Fnotes%2Fnotebooks%007-ce5c7935-0960-41f0-a5ce-e82a6d365f45&oneNoteWebUrl=https%3A%2F%2Fm365x432007.sharepoint.com%2Fsites%2FTaaP%2FSiteAssets%2FTaaP%2520Notebook&notebookName=TaaP%20Notebook&siteUrl=https%3A%2F%2Fm365x432007.sharepoint.com%2Fsites%2FTaaP&createdTeamType=Standard&oneNoteClientUrl=https%3A%2F%2Fm365x432007.sharepoint.com%2Fsites%2FTaaP%2FSiteAssets%2FTaaP%2520Notebook&notebookIsDefault=true&ui={locale}&tenantId={tid}&upn={userPrincipalName}&groupId={groupId}&theme={theme}&entityId={entityId}&subEntityId={subEntityId}&sessionId={sessionId}&ringId={ringId}&teamSiteUrl={teamSiteUrl}&channelType={channelType}&trackingId={appSessionId}&hostClientType={hostClientType}",
"removeUrl": "https://www.onenote.com/teams/TabRemove?notebookSource=Pick&notebookSelfUrl=https%3A%2F%2Fwww.onenote.com%2Fapi%2Fv1.0%2FmyOrganization%2Fgroups%2F46777f1c-3e3d-44ad-8206-53ba08a44cec%2Fnotes%2Fnotebooks%2F1-ce5c7935-0960-41f0-a5ce-e82a6d365f45&oneNoteWebUrl=https%3A%2F%2Fm365x432007.sharepoint.com%2Fsites%2FTaaP%2FSiteAssets%2FTaaP%2520Notebook&notebookName=TaaP%20Notebook&siteUrl=https%3A%2F%2Fm365x432007.sharepoint.com%2Fsites%2FTaaP&createdTeamType=Standard&oneNoteClientUrl=https%3A%2F%2Fm365x432007.sharepoint.com%2Fsites%2FTaaP%2FSiteAssets%2FTaaP%2520Notebook&notebookIsDefault=true&ui={locale}&tenantId={tid}&upn={userPrincipalName}&groupId={groupId}&theme={theme}&entityId={entityId}&subEntityId={subEntityId}&sessionId={sessionId}&ringId={ringId}&teamSiteUrl={teamSiteUrl}&channelType={channelType}&trackingId={appSessionId}&hostClientType={hostClientType}",
"websiteUrl": "https://www.onenote.com/teams/TabRedirect?redirectUrl=https%3A%2F%2Fm365x432007.sharepoint.com%2Fsites%2FTaaP%2FSiteAssets%2FTaaP%2520Notebook",
--> `oneNoteWebUrl=https%3A%2F%2Fm365x432007.sharepoint.com%2Fsites%2FTaaP%2FSiteAssets%2FTaaP%2520Notebook'
--> urldecode
https://m365x432007.sharepoint.com/sites/TaaP/SiteAssets/TaaP%20Notebook
The response of channels/{{ChannelId}}/tabs/{{tabid}} will contain details for tab and will not return details for the embedded onenote notebooks and pages. However you can get details for onenote notebooks and pages using https://graph.microsoft.com/v1.0/me/onenote/notebooks
You can refer below document for more information
https://learn.microsoft.com/en-us/graph/integrate-with-onenote
https://learn.microsoft.com/en-us/graph/api/resources/onenote-api-overview?view=graph-rest-1.0
Thanks

Ocelot swagger redirection issue

I am trying to implement Ocelot/Swagger/MMLib and .net microservices on my Windows 2019 server.
Everything is working fine, I can call each of the microservices correctly through the API gateway using postman, but I would like to display the swagger documentation as the API is going to be used by a third party.
If I use the ip address/port number I get the correct page displayed, with my microservice definitions. However if I reroute this to a physical url (eg https://siteaddress.com/path/swagger.index.html) I get the main swagger document but a 'Failed to load API definition' error, followed by 'Fetch error undefined /swagger/docs/v1/test.
The network page of my browser inspection gives a 'Http Error 404.0 Not Found'. The requested url is 'https://siteaddress.com:443/swagger/docs/v1/test'.
My ocelot.json is:
{
"Routes": [
{
"DownstreamPathTemplate": "/api/v1/TestSvc/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "test.api",
"Port": "80"
}
],
"UpstreamPathTemplate": "/api/v1/TestSvc/{everything}",
"UpstreamHttpMethod": [ "POST" ],
"SwaggerKey": "test"
}
...
],
"SwaggerEndPoints": [
{
"Key": "test",
"Config": [
{
"Name": "Test API",
"Version": "v1",
"Url": "http://test.api:80/swagger/v1/swagger.json"
}
]
}
...
]
}
I have tried changing paths in ocelot.json and startup.cs. I can see nothing in the MMLib documentation regarding this scenario, which is surely common in deploying these sites.
Suggestion on where to go next appreciated.
Page with ipaddress and port number
Page with physical address and error message

Can I use a friendly URL on SearchAction?

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>

Simple swagger specification, to retrieve an html web page

I'm new to swagger, and I'm trying to make a very simple specification, with only a get method in order to retrieve a web page, this is the code:
{
"swagger": "2.0",
"info": {
"title": "example",
"description": "Sample api to retrieve a web page.",
"version": "0.1"
},
"host":"example.org", #"localhost:8080",
"schemes": [
"https"
],
"paths": {
"/":{
"get":{
"summary":"Return the web page.",
"description":"",
"produces":["text/html"],
"responses":{
"200":{
"description":"OK",
},
"400":{
"description":"Bad request"
},
"404":{
"description":"Not Found"
}
}
}
}
}
}
I'm using the swagger online editor.
Unfortunately when I execute the request, it did not return the web page and no one of the status code that I have implemented in the specification, it return me in the detail section the error:
TypeError: Failed to fetch
Someone can tell me where I'm wrong?
Thank you.
For the "Try it out" button to work in the Swagger online editor, your API endpoints must be CORS-enabled. That is, your server (example.org or localhost:8080) must be configured to return certain response headers that would allow editor.swagger.io to make cross-domain requests to your server. This is explained in more details here:
https://github.com/swagger-api/swagger-ui#cors-support
The way to configure CORS depends on the server/framework used to host the app. This page has instructions for some common web servers:
https://enable-cors.org/server.html

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