How do I communicate from VB6 to a server-side PHP

2019-08-18 22:49发布

问题:

This is a question about communication between VB6 and server-side PHP.

WooCommerce has a plugin that lets you serialize sales of software products. It communications to software applications via a PHP API. The syntax of an API call is like this:

wp_get_request('http://174.120.19.162/~fab/?wc_api=software_api&request=request_key&Secret_Key=<sekret>&email=<email>')

I have a VB6 application that needs to communicate with this api. I am using the following code to send the URL request:

blah = INetObject.OpenURL("http://174.120.19.162/~fab/wp_get_request('http://174.120.19.162/~fab/?wc_api=software_api&request=request_key&Secret_Key=<sekret>&email=<email>')")

The API is supposed to return a JSON object (blah) which I then parse to get the data I want. However it is not working. I've tried various syntactical permutations to no avail. Mostly I get an XML description of the destination page, so my question is this:

How do I communicate to this API from VB6? I've been working this issue for about a week with no results.

回答1:

You're confusing the API to be used internally in wordPress code, and what you need to call externally.

This sample was given by you and calls a function internal to WordPress to make the HTTP request:

wp_get_request('http://174.120.19.162/~fab/?wc_api=software_api&request=request_key&Secret_Key=<sekret>&email=<email>')

The equivalant of the wp_get_request() in VB6 would be INetObject.OpenURL():

blah = INetObject.OpenURL('http://174.120.19.162/~fab/?wc_api=software_api&request=request_key&Secret_Key=<sekret>&email=<email>')

Your mistake was trying to mash the two together, thinking wp_get_request was part of the HTTP API itself.



标签: php http vb6