Need PHP expert for small gig $50 up for grabs

This is complicated for me… but might be easy for you :slight_smile:

I need to convert this PHP to xojo:

For this version, we use a standard HMAC-SHA512 signing. Append apikey and nonce to your request and calculate the HMAC hash and include it under an apisign header. Note: the nonce is not respected right now but will be enforced later.

$apikey='xxx'; $apisecret='xxx'; $nonce=time(); $uri='https://bittrex.com/api/v1.1/market/getopenorders?apikey='.$apikey.'&nonce='.$nonce; $sign=hash_hmac('sha512',$uri,$apisecret); $ch = curl_init($uri); curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:'.$sign)); $execResult = curl_exec($ch); $obj = json_decode($execResult);

Here is my attempt… which has yielded a badly formed request error. This is using MBS CURL plugin, but I’m willing to do whatever it takes…

[code] const apikey="900390c9267c5b5dcb21cff62b1ef "
const apisecret=“4fb35ab532464cd9a48f5db2bfa”
dim nonceDate as date
nonceDate = new date
dim nonce as string = str(nonceDate.TotalSeconds)

dim uri as string = “https://bittrex.com/api/v1.1/market/getopenorders?apikey=” + apikey + “&nonce=” + nonce
dim uriMemBlock as MemoryBlock = uri
dim sign as string = EncodeHex(Crypto.HMAC(apiSecret, uriMemBlock, Crypto.Algorithm.SHA512), false)

dim c as new CURLSMBS

c.OptionURL = uri
c.SetOptionHTTPheader array(“apisign:” + sign)
c.OptionVerbose = true
c.CollectDebugData = true
c.CollectOutputData = true
c.OptionSSLVerifyHost = 0
c.OptionSSLVerifyPeer = 0

dim e as integer = c.Perform

dim data as string = c.OutputData
TextArea1.text = data[/code]

My hunch is that… there’s some specific type of output that the PHP is putting out that xojo is not putting out as a request that is messing it up. Please help… I have paypal and bitcoin to use to pay to get this to work! :slight_smile: Thanks

The extra spaces in the apikey causing you issues ?

[code] const apikey=“900390c9267c5b5dcb21cff62b1ef”
const apisecret=“4fb35ab532464cd9a48f5db2bfa”
dim nonceDate as date
nonceDate = new date
dim nonce as string = str(nonceDate.TotalSeconds)

dim uri as string = “https://bittrex.com/api/v1.1/market/getopenorders?apikey=” + apikey + “&nonce=” + nonce
dim uriMemBlock as MemoryBlock = uri
dim sign as string = EncodeHex(Crypto.HMAC(apiSecret, uriMemBlock, Crypto.Algorithm.SHA512), false)

dim h as new HTTPSecureSocket
h.SetRequestHeader “apisign:” , sign
dim resp as string = h.Get(uri, 45)

break[/code]

with the trailing space on the API key you get a “request is badly formed” reply
remove that trailing space & you get “invalid api key” - which suggests its properly formed but invalid credentials

I would highly suggest to get the complete HTTP request of a working call from someone else (or php) and compare to yours.

Also didn’t I email you earlier today that time() and total seconds of a new date are not the same?
Does this server really need a unix time stamp?

unix time stamp should be

[code] dim d as new date
dim e as new date(1970,1,1)

MsgBox str(d.TotalSeconds - e.TotalSeconds, “-0”)
[/code]

I figured the nonce was not limited to anything special… but its funny because i took one look at @Norman Palardy 's suggestion and nearly dismissed it instantly cause i thought there’s no way i left that space in the actual code and even if i did it couldn’t be that… and whatddya know ? It was that… and I no am able to access API no problem thanks!

[quote=116533:@Christian Schmitz]unix time stamp should be

[code] dim d as new date
dim e as new date(1970,1,1)

MsgBox str(d.TotalSeconds - e.TotalSeconds, “-0”)
[/code][/quote]

Christian I really appreciate your help too, I wish there was a tip system built into the forums they should get on that :wink: There’s gotta be a way to plugin something for bitcoin. Anyhow i got it all working and now, I venture off to learn about parsing Json. Wish me luck and thanks again. I was sure it was going to be something super complex but… apparently it was just a typo.

Woohoo ! Beer money !
Come to the conference next year & buy me one and we’re good :slight_smile:

Any reason you’re not using the JSONItem class?

Now you awe $50 to Norman :wink:

:slight_smile: