0
我想爲Evernote創建一個小客戶端。無法通過Evernote Api授權
我從現場消費者密鑰和祕密寫了這樣的代碼:
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
而且總是趕有關錯誤的消費鍵錯誤。我究竟做錯了什麼?