我在使用第三方dll,lib和头文件时遇到问题。我试图调用一个函数,让它返回一个没有运气的值。 这是假设要调用的函数。
bool COAuthSDK :: GetRequestToken(CClientDetails& objClientDetails)
它有这个需要的信息
名称输入/输出描述 m_environment IN可选。可能的值是SANDBOX(默认)和LIVE。 m_strConsumerKey由E * TRADE提供的OAuth使用者密钥 m_strConsumerSecret在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
答案 0 :(得分:0)
GetRequestToken(CClientDetails &objClientDetails);
不好。你需要像
这样的东西COAuthSDK sdk;
sdk.GetRequestToken(objClientDetails);
请注意,它只是一些可能正确的语法,您应该从dox中找出如何获取sdk实例以供使用。