How do I use Oauth with C++ ?? Etrade API - c++

I am having problems with oauth. Let me start by saying that I have only been studying C++ for about a month. I am working on a Etrade API application. I have been struggling with this for a few weeks. Ok Etrade has provided the header, DLL and library files. I am having trouble just calling a simple function. Etrade list examples on how to call a Function for Java, and PHP but no C++. I just need a example for one function and I can pretty much go from there. here is a link to the API help
https://us.etrade.com/ctnt/dev-portal/getContent?contentUri=V0_Code-SDKGuides-VC
the arguments for the first function are
m_environment IN Optional. Possible values are SANDBOX (default) and LIVE.
m_strConsumerKey IN OAuth consumer key provided by E*TRADE
m_strConsumerSecret IN OAuth consumer secret provided by E*TRADE
m_strToken OUT Returned by the function if successful
m_strTokenSecret OUT Returned by the function if successful
m_strCallback IN Optional; default value is "oob"
Here is my code first function (oauth)
int main(int argc, char **argv)
{
}
bool COAuthSDK::GetRequestToken(CClientDetails &objClientDetails)
{
return GetRequestToken;
}

You're missing the point. ETrade provides you with COAuthSDK::GetRequestToken; You're supposed to call it, not re-implement it yourself. The m_ arguments are members of the CClientDetails object that you, as the client, have to provide.

Just a heads up. The Authorize URL in the docs(v0) is wrong! Doh! If you are having problems with that step, try the following URL.
Here is the correct URL: https://us.etrade.com/e/t/etws/authorize
Notice there is an additional 't' in the URL
BTW, I wrote a simple Node app called Trading Robo Monkey. If you have never used OAuth before, you can try to see if that was your problem by looking at the JS code
https://github.com/shikhirsingh/ETrade-API-Robo-Trading-Monkey-4-NodeJS

Related

while writing a Chaincode (Hyperledger-fabric) in Golang I am confused while fallowing documentation

I am confused ,when I am following fabric-samples (asset-transfer-basic --->https://github.com/hyperledger/fabric-samples/blob/main/asset-transfer-basic/chaincode-go/chaincode/smartcontract.go) for writing smart contract in Golang , the methods takes ctx contractapi.transcationcontextinterface as there function parameter , but when I am trying to refer other chaincode's on internet every one else are taking stub shim.chaincodesubinterface as there function parameter , if I use stub as my function parameter then how can I make use of clientidenty methods (cid package) , and in asset-transfer-basic code Init/Invoke are not mentioned also in main function when creating a new chaincode ( assetChaincode, err := contractapi.NewChaincode(&SmartContract{}) ) SmartContract{} does not implement contractinterface . I am try to do a project on ERC20 token for applying for jobs so please help
The examples you have found that include an Init and Invoke function, and take ChaincodeStubInterface as a parameter are using the older and lower-level fabric-chaincode-go API directly. The asset-transfer-basic sample is using the newer and higher-level fabric-contract-api-go API. This is built on top of the lower-level API and allows you access to all the same information as the lower-level API (note that the transaction context passed into transaction functions using the higher-level API has a GetStub method to obtain the corresponding low-level ChaincodeStubInterface).
I would recommend using the Contract API as demonstrated by the asset-transfer samples. The two approaches are functionally equivalent but the Contract API provides a cleaner abstraction requiring less boiler-plate code.

Web Service authorization issue

Need some help with KDSoap 1.7 or gSOAP
I'm trying to use some Web Service API: http://sparkgatetest.interfax.ru/iFaxWebService/ . There is list of methods and to interact with them u must:
call Authmethod
call any method u need to
call End
Problem is, this is HTTP protocol, so if you used Authmothod succesfully, and after that trying to call methods which return some information, u got an "Authorization error" message in xml response.
So, to correct usage of this API u should call three methods (Authmethod, some method, End) in one request. How should I do it with KDSoap/gSOAP?
p.s. i found setAuthentication function in client interface, but it takes KDSoapAuthentication class as argument, maybe there is a way to customize it? And End method also a big problem aswell.

webrtc - GetStats() call OnStatsDelivered with an empty RTCStatsReport

I'm using new WebRTC stats API with RTCStatsCollectorCallback object that is called when stats report is generated. I'm invoke GetStats() and then I can see that OnStatsDelivered is called with a RTCStatsReport that contains just one (empty) item in stats_ member. In GetStats() call I pass my own implementation of RTCStatsCollectorCallback that implements webrtc::RTCStatsCollectorCallback interface. My question is, is neccessary some setup or constraints in PeerConnection in order to get RTCStatsReport with the metrics? I mean, to get, for example kStatsValueNameRtt stat, I need to set something in PeerConnection. Note that I'm using C++ native API in branch 55. Is this new stats API full implemented?
I've used the older GetStats method with success:
bool GetStats(StatsObserver* observer,
webrtc::MediaStreamTrackInterface* track,
StatsOutputLevel level) override;
It could be your problem was due to trying to use an in-progress API (webrtc framework is a bit wild west). Currently, peerconnectiointernface.h says the following:
// Gets stats using the new stats collection API, see webrtc/api/stats/. These
// will replace old stats collection API when the new API has matured enough.
// TODO(hbos): Default implementation that does nothing only exists as to not
// break third party projects. As soon as they have been updated this should
// be changed to "= 0;".
virtual void GetStats(RTCStatsCollectorCallback* callback) {}
As I'm writing this response, your question is 6 months old, so it's possible the this new API is now working (though the comment above suggests otherwise).

c++ send request to API on webserver then receive json array response?

I'm wondering the most simple way to send a request to a API on my server then receive the API's response (json array) wihtout using any libraries. I've tried using libs like cURL & boost without any luck which is the reason i want to stay away from them. I've searched for many days for a answer and have not been able to find anything, which is why i've resorted to coming to the stack overflow community!
Even though the question is about not using a library I 'am taking this opportunity to show how easy it is to use a library than the user thinks.
Its better to use pre-built libraries and stop reinventing the wheel. You can use curlcpp library. Its a wrapper for libcurl. Using this library HTTP requests can be made easily. Learning curve is also less and it provides C++ style access which makes it more comfortable to work with.
The following code is taken from their gitHub page - https://github.com/JosephP91/curlcpp
It makes a simple GET request to Google and retrieves the HTML response. You can use this example to hit apis too.
#include "curl_easy.h"
#include "curl_exception.h"
using curl::curl_easy;
using curl::curl_easy_exception;
using curl::curlcpp_traceback;
int main(int argc, const char **argv) {
curl_easy easy;
// Add some option to the curl_easy object.
easy.add<CURLOPT_URL>("http://www.google.it");
easy.add<CURLOPT_FOLLOWLOCATION>(1L);
try {
// Execute the request.
easy.perform();
} catch (curl_easy_exception error) {
// If you want to get the entire error stack we can do:
curlcpp_traceback errors = error.get_traceback();
// Otherwise we could print the stack like this:
error.print_traceback();
// Note that the printing the stack will erase it
}
return 0;
}

How to call Soap\WSDL Service through a login required webpage using matlab?

I am new to the wsdl\soapmessage query\reply world( if i can put it in this way), and I am facing some difficulties using the following wsdl( which I really really hope, one will be so kind to look at at least one of the services described there)
http://almdemo.polarion.com/polarion/ws/services/TrackerWebService?wsdl
which was provided to me to develop a matlab webinterface. Right now my matlab code looks like this:
targetNamespace = 'http://ws.polarion.com/TrackerWebService';
method = 'queryWorkItems';
values= {'Query','Sort'}
names = {'query', 'sort'}
types ={'xsd:string','xsd:string'}
message = createSoapMessage( targetNamespace, method, values, names, types)
response = callSoapService('http://almdemo.polarion.com/polarion/ws/services',...
% Service's endpoint
'http://almdemo.polarion.com/polarion/#/workitems',...
% Server method to run
message)
% SOAP message created using createSoapMessage
author = parseSoapResponse(response)
Herewith to save you time I will just enonce my two problems:
Is the code correct?
Could someone tell me if such a wsdl link is just a definition of webservices or it is also a service's endpoint?
Normally to execute manually\per clicks this services on the weppage
http://almdemo.polarion.com/polarion, you have to login!
So how do I send a message in matlab which first log me in? Or must such a service be introduced into that wsdl for me to do it?? Could you be kind enough to write how it must be defined, because I don't really
write wsdl files, but I shall learn!**
I will be really thankful for your help and I wish you a happy week(-end) guys(& girls)!!!
Regards
Chrysmac
ps: I tried to use Soapui and gave that webpage as endpoint, but the toool crashes each time I enter my credentials! Maybe because of the dataload!??