0

我想为 Evernote 创建一个小客户端。

我从该站点获得了消费者密钥和秘密并编写了以下代码:

struct user_data {
    std::string login;
    std::string pass;
};

struct evernote_data {
    user_data user;
    std::string consumer_key;
    std::string consumer_secret;
};

struct service_data
{
    std::string host;
    std::string path;
    int port;
};

void connect(const evernote_data& account, const service_data&  service)
{
    try
    {
        boost::shared_ptr<TSSLSocketFactory> sslSocketFactory(new TSSLSocketFactory());
        boost::shared_ptr<TSSLSocket> sslSocket=sslSocketFactory->createSocket(service.host, service.port);
        boost::shared_ptr<TBufferedTransport> bufferedTransport(new TBufferedTransport(sslSocket));
        boost::shared_ptr<TTransport> http_client(new THttpClient(bufferedTransport, service.host, service.path));
        http_client->open();
        boost::shared_ptr<TBinaryProtocol> user_store_protocol(new TBinaryProtocol(http_client));
        evernote::edam::UserStoreClient user_store(user_store_protocol, user_store_protocol);

        evernote::edam::AuthenticationResult auth_result;
        user_store.authenticate(auth_result, account.user.login, account.user.pass, account.consumer_key, account.consumer_secret);
        cout << "Some info: " ;
        cout << auth_result.user.username << endl << auth_result.user.name << endl << auth_result.user.email << endl;
    }
    catch(evernote::edam::EDAMUserException& error)
    {
        cout << "catch EDAMUserException" << endl;
        cout << "ErrorCode: " << error.errorCode << endl;
        cout << "What: " << error.what() << endl;
        cout << "Parameter: " << error.parameter << endl;
    }
    catch(::apache::thrift::TException& error)
    {
        cout << "catch thrift::TException " << endl;
        cout << "What: " << error.what() << endl;
    }
    catch(...)
    {
        cout << "boom !!!" << endl;
    }
}

int main()
{
    const user_data user = { "**Login**", "**password**"};
    const evernote_data account = { user, "***Key***", "**Secret**" };
    const service_data service = {"sandbox.evernote.com", "/edam/user", 443 };
    connect(account, service);

    std::cout << "Exit" << std::endl;
    cin.get();
    return 0;
}

程序输出:

Catch EDAMUserException 
ErrorCode: 8 
What: Default TException.
Parameter: consumerKey

并始终捕获有关错误消费者密钥的错误。我究竟做错了什么?

4

1 回答 1

0

自去年 11 月以来,第三方开发者无法使用 UserStore#authenticate。 http://dev.evernote.com/documentation/reference/UserStore.html#Fn_UserStore_authenticate

请改用 OAuth。 http://dev.evernote.com/start/core/authentication.php

于 2013-04-08T18:21:15.887 回答