GET / POST using Clarion

Viewed 1026

I have Clarion 9 app that I want to be able to communicate with HTTP servers. I come from PHP background. I have 0 idea on what to do.

What I wish to be able to do:

  • Parse JSON data and convert QUEUE data to JSON [Done]

  • Have a global variable like 'baseURL' that points to e.g. http://localhost.com [Done]

  • Call functions such apiConnection.get('/users') would return me the contents of the page. [I'm stuck here]

  • apiConnection.post('/users', myQueueData) would POST myQueueData contents.

I tried using winhttp.dll by reading it from LibMaker but it didn't read it. Instead, I'm now using wininet.dll which LibMaker successfully created a .lib file for it.

I'm currently using the PROTOTYPE procedures from this code on GitHub https://gist.github.com/ddur/34033ed1392cdce1253c

What I did was include them like:

SimpleApi.clw

PROGRAM
     INCLUDE('winInet.equ')
      ApiLog    QUEUE, PRE(log)
      LogTitle  STRING(10)
      LogMessage    STRING(50)
     END

     MAP
      INCLUDE('winInetMap.clw')
     END

     INCLUDE('equates.clw'),ONCE 
     INCLUDE('DreamyConnection.inc'),ONCE

     ApiConnection     DreamyConnection

CODE

    IF DreamyConnection.initiateConnection('http://localhost')
       ELSE
          log:LogTitle = 'Info'
          log:LogMessage = 'Failed'
          ADD(apiLog)
    END

But the buffer that winInet's that uses always returns 0.

I have created a GitHub repository https://github.com/spacemudd/clarion-api with all the code to look at.

I'm really lost in this because I can't find proper documentation of Clarion.

I do not want a paid solution.

1 Answers
Related