您是否知道evernote小部件使用的方法或方法来检索我们在主界面或小部件中以非常方便的方式(在检索整个笔记之前)看到的缩略图?我看到了通过http请求的post方法,但当不共享笔记时,它似乎很复杂,也许有更简单的方法,通过直接evernote API调用或通过读取应用程序存储的文件?
发布于 2013-07-23 07:01:14
该小工具从Evernote应用程序的内容提供商中提取缩略图。
像这样的东西应该行得通。
在您的清单中:
<permission android:name="evernote.permission.READ_DATA" android:protectionLevel="normal" />在你的java代码中:
final Uri AUTHORITY_URI = Uri.parse("content://com.evernote.evernoteprovider");
final Uri NOTE_URI = Uri.withAppendedPath(AUTHORITY_URI, "notes");
private FileDescriptor getNoteThumbnail(Context context, String noteGuid) throws FileNotFoundException {
Uri thumbnailUri = NOTE_URI.buildUpon().appendEncodedPath(noteGuid).appendPath("thumbnail").appendPath("data").build();
ContentResolver cr = context.getContentResolver();
return cr.openFileDescriptor(thumbnailUri, "r").getFileDescriptor();
}发布于 2014-07-23 05:54:28
HTTP Post方法并不太复杂。我不熟悉Java,但这是一个用python编写的示例,它可以非常直接地移植到android:
import requests
ACCESS_TOKEN="INSERT YOUR AUTH TOKEN OR DEV TOKEN HERE"
payload={'auth':ACCESS_TOKEN} #map auth token to param "auth"
r=requests.post('https://sandbox.evernote.com//shard/s1/thm/note/e679c010-d8b2-4644-9eag-56bd31c84be7.jpg?size=75',data=payload, stream=True) #returns a binary of the picture type in header
f=open('thumbnail.jpg','wb') #open file for binary writing
f.write(r.content) #write binary contents of request to a file
f.close() #close the filePOST请求的唯一参数是" auth“,它应该包含您的auth标记(或dev标记)。其余信息来自URL本身,格式如下:
[domain].evernote.com/shard/[shard]/thm/note/[guid]哪里
域名为沙箱(沙箱)和www (生产)
分片是账户所在的分片(应该类似于s1)
guid是笔记本guid
将可选参数附加到.jpg、.gif、.bmp或.png的末尾,并将可选参数附加到URL ?size=1 to 299的末尾
例如,在包含分片s1的沙箱上,注意guid "e669c090-d8b2-4324-9eae-56bd31c64af7“,以返回大小为150px正方形的jpg,URL将如下所示:
https://sandbox.evernote.com/shard/s1/thm/note/e669c090-d8b2-4324-9eae-56bd31c64af7.jpg?size=75https://stackoverflow.com/questions/17124294
复制相似问题