小编Ric*_*cky的帖子

将十六进制字符串转换为字节数组

我的问题是:
如何成功使用getResourceByHash(...)Evernote API 的方法?

我做了什么:
我在笔记内容中得到了em-media的十六进制哈希:80ad525cd14de8f925487c02afc9ab21

然后我使用以下函数将十六进制转换String为字节:

function hex2bin(hex){
    var bytes = [];
    for(var i=0; i< hex.length-1; i+=2) {
        bytes.push(parseInt(hex.substr(i, 2), 16));
    }
    return String.fromCharCode.apply(String, bytes);    
}

var bin = hex2bin("80ad525cd14de8f925487c02afc9ab21");
Run Code Online (Sandbox Code Playgroud)

接下来,我getResourceByHash(...) 以这种方式将变量应用于函数:

noteStore.getResourceByHash(GUID, bin, true, true, true, 
    function(err,result){
        console.log(err);
        console.log(result);
    }
);
Run Code Online (Sandbox Code Playgroud)

但输出结果如下:

{identifier: 'Resources', key: 'c280c2ad525cc3914dc3a8c3b925487c02c2afc389c2ab21'}
undefined
Run Code Online (Sandbox Code Playgroud)

总之,我很困惑.

javascript evernote node.js

3
推荐指数
1
解决办法
5042
查看次数

标签 统计

evernote ×1

javascript ×1

node.js ×1