Solved

Can I Run JSON On Windows Server 2003?

Posted on 2014-04-23
10
550 Views
Last Modified: 2016-02-26
Hello everyone,

I am new to this so please bear with my ignorance.  :-)

The site is hosted on Windows Server 2003 Enterprise.  The site operates in classic ASP.

Currently the site uses SOAP API for it's ecommerce.  I am interested in adding Bitcoin processing to it.  Bitpay.com and Coinbase.com use JSON, something I am not familiar with but am able to learn.

My dilemma is after researching online for a while, I can't find anything to show if I am able to use JSON on Windows 2003 Server Ent.

I am now testing Coinbase.com's API.  It offers .PHP examples to open the Bitcoin payment popup, so I also made the server run .php pages as well... problem is the CallbackURL (post back with results of the transaction) is via JSON and after several tries using their system, my CallbackURL isn't able to capture the post details for me to Response.Write the code so that I can see how to  parse out the values to insert into my database.

I've considered upgrading to Server 2008, however am a littler leery doing it because of the fear of other issues arising.

Any example codes, ideas, help in the right direction is very much appreciated.

Looking forward, thanks.
0
Comment
Question by:Digicoin
  • 5
  • 4
10 Comments
 
LVL 51

Assisted Solution

by:Julian Hansen
Julian Hansen earned 500 total points
Comment Utility
JSON is just a data format - it is not reliant on the Operating System - or even (in a strict sense) the development environment. It is preferable that your dev environment includes support for processing JSON data - but it is possible to process it without having implicit support.

Consider an array "details"
details['name'] = 'John'
details['accnp' = 2101

Open in new window

A JSON representation of this would look like
{"name":"John","accno":2101}

Open in new window


So to process JSON you need to be able to turn JSON strings into internal objects / variables / arrays that you can then use in your code.

For ASP you could consider using this library

http://www.aspjson.com/
0
 
LVL 16

Expert Comment

by:hankknight
Comment Utility
Here is as tutorial:
http://gopalkaroli.wordpress.com/2013/08/01/how-to-parse-json-in-classic-asp/

Here are two free project libraries for generating and reading JSON data using classic ASP:
http://www.aspjson.com/
https://code.google.com/p/aspjson/
0
 

Author Comment

by:Digicoin
Comment Utility
Thank you for your very informative responses.  I apologize for the delay of my responses, my father passed on Easter Sunday and I've been handling family arrangements.  He suffered Parkingson's Disease all his life, he is at peace now.

Ok, I have a better understanding now what JSON is.  What I'm trying to do is to write data to, and retrieve data back from Coinbase.com   I'm looking to add Bitcoin to a new site.

In Coinbase, I have to authenticate my credentials to them first.  Their example is:

GET /api/v1/account/balance HTTP/1.1
Accept: */*
User-Agent: Ruby
ACCESS_KEY: <YOUR-API-KEY>
ACCESS_SIGNATURE: <YOUR-COMPUTED-SIGNATURE>
ACCESS_NONCE: <YOUR-UPDATED-NONCE>
Connection: close
Host: coinbase.com

I have my API-KEY and COMPUTED-SIGNATURE

I believe the NONCE is a number that needs to update for every request, like:
ACCESS_NONCE: 1, then to
ACCESS_NONCE: 2
etc...

They offer PHP samples, but I write ASP (old school).  Can anyone show me how I can send my credentials first?  I am trying out aspjson.com

Thanks,
Digicoin
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
I would suggest working through the links posted above and if you get stuck post he code you have compiled so far.
0
 

Author Comment

by:Digicoin
Comment Utility
Already looked at links. Reading and writing seems easy enough, but it's the authenticating first that I'm lost on. I'll keep resourcing and trying to figure it out.

If anyone has experience or has the free Coinbase acct to see their merchant API will probably understand what I'm asking. Thx.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
Here is a tutorial on using ASP and OAuth to connect to twitter.

http://scottdesapio.com/VBScriptOAuth/

There might be some information in there that will be of assistence.
0
 

Author Comment

by:Digicoin
Comment Utility
Thank you julianH for your suggestion, however that won't work with Coinbase.

I wrote to Coinbase and showed them this:

------------------------------------------------------------
<!--#include virtual=" aspJSON1.17.html" -->
<%
'COINBASE REQUIRES A NEW INTEGER FOR EVERY REQUEST, A NONCE
' THIS INCREMENTS THE NONCE VALUE
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.OpenTextFile("C:\Sites\mydomain.com\nonce_counter.txt")
CurrentNonce = Clng(a.ReadLine)
CurrentNonce = CurrentNonce + 1
a.close
Set a = fs.CreateTextFile("C:\Sites\mydomain.com\nonce_counter.txt")
a.WriteLine(CurrentNonce)
a.Close
Set a = Nothing
Set fs = Nothing

‘ I USE A WINDOWS SCRIPTING COMPONENT TO DUPLICATE PHP's hash_hmac FUNCTION
Dim sha256
Set sha256 = GetObject( "script:" & Server.MapPath("mysha256.wsc") )
sha256.hexcase = 0

‘AN ACCESS SIGNATURE IS REQUIRED BY COINBASE
'THIS HASHES THE NONCE + URL, USING MY ACCESS SECRET
Dim AccessSignature
AccessSignature = sha256.hmac_sha256(ACCESS_SECRET, CurrentNonce & "https://coinbase.com/api/v1/buttons?nonce=" & CurrentNonce & "&access_key=ACCESS_KEY")

‘THIS CREATES THE JSON STRUCTURE
Set oJSON = New aspJSON

With oJSON.data

                .Add "ACCESS_KEY", "ACCESS_KEY"
                .Add "ACCESS_SECRET", "ACCESS_SECRET"
                .Add "ACCESS_SIGNATURE", AccessSignature
                .Add "ACCESS_NONCE", CurrentNonce

                .Add "button", oJSON.Collection()

    With oJSON.data("button")

        .Add 0, oJSON.Collection()                  'Create object
        With .item(0)
            .Add "name", "Your Checkout Items"
            .Add "type", "buy_now"
            .Add "price_string", "10.00"
            .Add "price_currency_iso", "USD"
            .Add "custom", "Order123"
            .Add "callback_url", "https://mydomain.com/callback.html"
            .Add "success_url", "https://mydomain.com/success.html"
            .Add "description", "Bitcoin Transaction"
            .Add "include_email", false
        End With

    End With

End With

Response.Write oJSON.JSONoutput()    'Return json string

So, how to I authenticate it on your servers so I can get a return value for the checkout button?
------------------------------------------------------------

Coinbase in return wrote back with this:
------------------------------------------------------------
Requests aren't actually sent as JSON — they're sent as stringified arrays. JSON's just easier to work with at the outset, and can easily be passed between platforms and converted to other array formats.

A complete PHP cURL request for generating a button would look like this:

$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => "https://coinbase.com/api/v1/buttons",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
"ACCESS_KEY: " . $apikey,
"ACCESS_NONCE: " . $nonce,
"ACCESS_SIGNATURE: " . hash_hmac("sha256", $nonce . "https://coinbase.com/api/v1/buttonsbutton[name]=test&button[price_string]=1.23&button[price_currency_iso]=USD&button[variable_price]=1", $apisecret)
),
CURLOPT_POSTFIELDS => "button[name]=test&button[price_string]=1.23&button[price_currency_iso]=USD&button[variable_price]=1",
CURLOPT_POST => true
));
$results = curl_exec($ch);
curl_close($ch);
echo $results

If you were to just copy and paste your API key, secret, and nonce into that code and then run it on your server, it would work.

No-one on our team is knows ASP, and so I'm afraid we won't be able to give you much explicit help when it comes to the actual syntax of your request.
------------------------------------------------------------

I need help in converting their PHP cURL version into ASP so that I can authenticate my account.   Again, THANK YOU for your time and help.

Digicoin
0
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 500 total points
Comment Utility
Cant port it for you as having difficulty signing up for a coinbase account . But here is the direction you want to be going in
function getHTML (strUrl, data)
    Set xmlHttp = Server.Createobject("MSXML2.ServerXMLHTTP")
    xmlHttp.Open "POST", strUrl, False
    xmlHttp.setRequestHeader "User-Agent", "asp httprequest"
    xmlHttp.setRequestHeader "content-type", "application/x-www-form-urlencoded"
    xmlHttp.Send data
    getHTML = xmlHttp.responseText
    xmlHttp.abort()
    set xmlHttp = Nothing   
end function
' you would need to change the data parameter in the call below and potentially add some headers
' to the getHTML function above.
x = getHTML("https://coinbase.com/api/v1/buttons", "val=2")
Response.write "<pre>" & x & "</pre>"

Open in new window

0
 

Author Closing Comment

by:Digicoin
Comment Utility
julianH, thank you.  You've been the most helpful!

Digicoin
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
You are welcome thanks for the points.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now