我在写一个网页博客应用的时候,想要从Evernote获取笔记下来,按照官方的API文档的做法,会提示跨域。
但是,使用node.js就可以很轻松的获取下来。
以下是我的代码:
/* 使用了jsOAuth库 */
var oauth = OAuth({
consumerKey: '',
consumerSecret: '',
callbackUrl : 'http://0.0.0.0:9000',
signatureMethod : "HMAC-SHA1"
});
oauth.request({
'method': 'GET',
'url': config.BLOG_ROOT_URL + '/oauth', //config.BLOG_ROOT_URL即'https://sandbox.evernote.com'
success: function () {}
});
然后会出现下面的提示:
XMLHttpRequest cannot load https://sandbox.evernote.com/oauth. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://0.0.0.0:9011' is therefore not allowed access.
我想问的是,我前端这边可以处理这个跨域吗?还是说Evernote不支持网页端获取数据?
在浏览器上跨域可以实现,但都比较麻烦
http://www.cnblogs.com/rainman/archive/2011/02/20/1959325.html