0

我在使用第三方 dll、库和头文件时遇到问题。我正在尝试调用一个函数并让它返回一个没有运气的值。这是假设要调用的函数。

bool COAuthSDK::GetRequestToken(CClientDetails &objClientDetails)

它有它需要的信息

名称 IN/OUT 描述 m_environment IN 可选。可能的值为 SANDBOX(默认)和 LIVE。m_strConsumerKey IN E*TRADE 提供的 OAuth 消费者密钥 m_strConsumerSecret IN E*TRADE 提供的 OAuth 消费者密钥 m_strToken OUT 如果成功则由函数返回 m_strTokenSecret OUT 如果成功则由函数返回 m_strCallback IN 可选;默认值为“oob”

这是 COAuthSDK 标头。

#ifndef _OAUTHSDK_H_INCLUDED_
#define _OAUTHSDK_H_INCLUDED_

#include "ETCOMMON\CommonDefs.h"
#include "ETCOMMON\OAuthHelper.h"
using namespace std;

#ifdef OAUTH_LIBRARY_EXPORT // inside DLL
#   define OAUTH_API   __declspec(dllexport)
#else //outside DLL
#   define OAUTH_API   __declspec(dllimport)
#endif  //OAUTH_LIBRARY_EXPORT

class OAUTH_API COAuthSDK
{
public:
COAuthSDK(void);
virtual ~COAuthSDK(void);

bool GetRequestToken(CClientDetails &objClientDetails) throw (...);
bool GetAccessToken(CClientDetails &objClientDetails,string strVerifier) throw (...);
void RenewToken(CClientDetails &objClientDetails) throw (...);
void RevokeToken(CClientDetails &objClientDetails) throw (...);
string AuthorizeUrl(CClientDetails &objClientDetails) throw (...);

string GetProtectedResourse(CClientDetails &objClientDetails,string strUrl,       HttpMethodConstants httpMethod = GETMethod, string postParameters = NULL) throw (...);

};

#endif//_OAUTHSDK_H_INCLUDED_

和 CClientDetails 标头

#pragma once

#ifndef _CLIENTDETAILS_H_INCLUDED_
#define _CLIENTDETAILS_H_INCLUDED_

using namespace std;

#include "CommonDefs.h"

#ifdef COMMON_LIBRARY_EXPORT // inside DLL
#   define COMMON_API   __declspec(dllexport)
#else // outside DLL
#   define COMMON_API   __declspec(dllimport)
#endif  // COMMON_LIBRARY_EXPORT

class COMMON_API CClientDetails
{
public:
CClientDetails();
CClientDetails(string strConsumerKey,string strConsumerSecret,Environment environment);
virtual ~CClientDetails ();

Environment GetEnv();
void SetEnv(Environment env);

string GetConsumerKey();
void SetConsumerKey(string consumerKey);

string GetConsumerSecret();
void SetConsumerSecret(string consumerSecret);

string GetToken();
void SetToken(string token);

string GetTokenSecret();
void SetTokenSecret(string tokenSecret);

private :
Environment m_environment;
string m_strConsumerKey;
string m_strConsumerSecret;
string m_strToken;
string m_strTokenSecret;
string m_strCallback;
};
#endif//_CLIENTDETAILS_H_INCLUDED

和我的主要 CPP。

int _tmain(int argc, _TCHAR* argv[]){CClientDetails clientDetails;

CClientDetails objClientDetails;
GetRequestToken(CClientDetails &objClientDetails);
objClientDetails.SetEnv(SANDBOX);
objClientDetails.SetConsumerKey("1f5328f725dee654e0a4499f161b8fe4c6e");
objClientDetails.SetConsumerSecret("d39a8043cc0c7686920fd0655e47281e6a5");
objClientDetails.GetToken();
objClientDetails.GetTokenSecret();
cin.get();
cin.get();
return 0;

  }`

当我尝试构建函数时,它说它在 dll 中,所以我知道我必须调用它。如果有人可以提供帮助,将不胜感激。如果需要,这里是构建站点的链接https://us.etrade.com/ctnt/dev-portal/getContent?contentUri=V0_Code-SDKGuides-VC

4

1 回答 1

0
GetRequestToken(CClientDetails &objClientDetails);

不好。你需要类似的东西

COAuthSDK sdk;
sdk.GetRequestToken(objClientDetails);

请注意,这只是一些可能正确的语法,您应该从 dox 中弄清楚如何获取 sdk 实例以供使用。

于 2013-06-25T22:04:56.943 回答