OneNote API中以任何方式提取到另一个OneNote页面的链接? [英] Any way in OneNote API to extract link to another OneNote page?

查看:167
本文介绍了OneNote API中以任何方式提取到另一个OneNote页面的链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们在HTML内容中具有指向另一个OneNote页面的链接:

If we have a link to another OneNote page in the HTML content:

<a href="onenote:SectionB.one#Note1&amp;section-id={<section-id>}&amp;page-id={<page-id>}&amp;end&amp;base-path=https://<path>"

...在编写解析例程以提取该链接之前,我想过要问我是否会忽略OneNote API中的任何内容以使其变得更容易.

... before I write a parsing routine to extract that link, I thought I'd ask if I'd overlooked anything in the OneNote API to make this easier.

================================================ ==========================

===========================================================================

好吧,我已经编写了例程来提取链接笔记的page-id,但是事实证明,该page-id与作为属性(id)返回的page-id完全不同.链接的便笺本身-它不起作用:(

Well, I've written my routine to extract the page-id of the linked note, but that page-id turns out to be quite different from the page-id that's returned as a property (id) of the linked note itself - and it doesn't work :(

这是一个例子:

(1)从链接A8CECE6F-6AD8-4680-9773-6C01E96C91D0

(2)页面ID作为注释的属性:

(2) page-id as property of note:

0-5f49903893f048d0a3b1893ef004411f!1-240BD74C83900C17!124435

您所看到的完全不同.通过以下方式访问页面内容:

Vastly different, as you see. Accessing the page content via:

 ../pages/{page-id}/content

...对于(1)来说什么都不返回

... for (1) returns nothing

... for(2)返回整个页面内容.

... for (2) returns the full page content.

(这两种方法返回的section-id也完全不同.)

(The section-ids returned by both methods are also entirely different.)

那么,如何从链接中提取有效的页面ID?

So, how can I extract from the link a page-id that works?

推荐答案

不幸的是,OneNote API当前不支持在页面内容中标识到其他OneNote页面的链接. OneNote中的链接可以是任何内容的链接:网站,其他OneNote页面/部分/笔记本,网络共享... 该API确实支持通过使用

Unfortunately, the OneNote API currently does not support identifying links to other OneNote pages in page content. Links in OneNote can be links to anything: websites, other OneNote pages/sections/notebooks, network shares... The API does support getting links to pages by using

    GET ~/pages
    GET ~/sections/id/pages

页面元数据模型包含一个带有clientUrl和webUrl的链接对象.

The page metadata model contains a links object with the clientUrl and the webUrl.

问题更新后进行 您是对的-链接中的ID与OneNote API的ID不对应.但是,您可以将链接中的ID与API中公开的OneNoteClientUrl中的ID进行比较.这是一个响应的示例

Editing after your question update: You're right - the id in the link does not correspond to the id of the OneNote API. You can however compare the id in the link with the id in the OneNoteClientUrl exposed in the API. Here's an example of the response of a

    GET ~/sections/id/pages
    GET ~/pages

{ "title":从WAC创建", "createdByAppId":", 链接":{ "oneNoteClientUrl":{ "href":"onenote: }, "contentUrl":" https://www.onenote.com/api/v1.0/me/notes/pages/0-a50842a9873945379f3d891a7420aa39!14-29056CF89BB2D216!162/content ", "thumbnailUrl":" https://www.onenote.com/api/v1.0/me/notes/pages/0-a50842a9873945379f3d891a7420aa39!14-29056CF89BB2D216!162/thumbnail ", "lastModifiedTime":"2016-03-28T21:36:22Z", "id":"0-a50842a9873945379f3d891a7420aa39!14-29056CF89BB2D216!162", "self":" https://www.onenote.com/api/v1.0/me/notes/pages/0-a50842a9873945379f3d891a7420aa39!14-29056CF89BB2D216!162 ", "createdTime":"2016-03-24T20:38:16Z", "parentSection@odata.context":" https://www.onenote.com/api/v1 .0/ $ metadata#me/notes/pages('0-a50842a9873945379f3d891a7420aa39%2114-29056CF89BB2D216%21162')/parentSection(id,name,self)/$ entity, "parentSection":{ "id":"0-29056CF89BB2D216!162", "name":"Harrie's Section", "self":" https://www. onenote.com/api/v1.0/me/notes/sections/0-29056CF89BB2D216!162 " } }

{ "title": "Created from WAC", "createdByAppId": "", "links": { "oneNoteClientUrl": { "href": "onenote:https://d.docs.live.net/29056cf89bb2d216/Documents/TestingNotification/Harrie%27s%20Section.one#Created%20from%20WAC&section-id=49b630fa-26cd-43fa-9c45-5c62d547ee3d&page-id=a60de930-0b03-4527-bf54-09f3b61d8838&end" }, "oneNoteWebUrl": { "href": "https://onedrive.live.com/redir.aspx?cid=29056cf89bb2d216&page=edit&resid=29056CF89BB2D216!156&parId=29056CF89BB2D216!105&wd=target%28Harrie%27s%20Section.one%7C49b630fa-26cd-43fa-9c45-5c62d547ee3d%2FCreated%20from%20WAC%7Ca60de930-0b03-4527-bf54-09f3b61d8838%2F%29" } }, "contentUrl": "https://www.onenote.com/api/v1.0/me/notes/pages/0-a50842a9873945379f3d891a7420aa39!14-29056CF89BB2D216!162/content", "thumbnailUrl": "https://www.onenote.com/api/v1.0/me/notes/pages/0-a50842a9873945379f3d891a7420aa39!14-29056CF89BB2D216!162/thumbnail", "lastModifiedTime": "2016-03-28T21:36:22Z", "id": "0-a50842a9873945379f3d891a7420aa39!14-29056CF89BB2D216!162", "self": "https://www.onenote.com/api/v1.0/me/notes/pages/0-a50842a9873945379f3d891a7420aa39!14-29056CF89BB2D216!162", "createdTime": "2016-03-24T20:38:16Z", "parentSection@odata.context": "https://www.onenote.com/api/v1.0/$metadata#me/notes/pages('0-a50842a9873945379f3d891a7420aa39%2114-29056CF89BB2D216%21162')/parentSection(id,name,self)/$entity", "parentSection": { "id": "0-29056CF89BB2D216!162", "name": "Harrie's Section", "self": "https://www.onenote.com/api/v1.0/me/notes/sections/0-29056CF89BB2D216!162" } }

您还可以使用以下方法过滤链接中id的服务器端(如果您想避免使用分页和正则表达式的;)).

You can also filter server side (if you want to save yourself from paging and regex's ;) ) for id's in the links by using:

    GET ~/pages?$filter=contains(links/oneNoteClientUrl/href,'a60de930-0b03-4527-bf54-09f3b61d8838')

这篇关于OneNote API中以任何方式提取到另一个OneNote页面的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆