1/*
2 * Rexx/CURL sample program to execute a HTTP POST to a web server.
3 * This example, subscribes the user to the rexxcurl-users mailing
4 * list at SourceForge.
5 * Pass the email address and password on the command line.
6 */
7
8Call RxFuncAdd 'CurlLoadFuncs', 'rexxcurl', 'CurlLoadFuncs'
9Call CurlLoadFuncs
10
11site = 'http://centos-65-amd64/paddleed/test.php'
12username = 'markhessling'
13password = 'pfmoe09'
14
15curl = CurlInit()
16If curl \= '' Then
17   Do
18      Say 'We are running' CurlVariable('VERSION')
19
20      Call CurlSetopt curl, 'HTTPPOST', 1
21      field.1 = 'username='username
22      field.2 = 'password='password
23      field.3 = 'version=PaddleEd-MacOS-1.1.3'
24      field.4 = 'data=[{"acId":0,"firstName":"Fred","surname":"Bloggs","qualId":153},{"acId":"undefined","firstName":"Mary","surname":"Bloggs","qualId":153},{"acId":0,"firstName":"Donald","surname":"Bloggs","qualId":153}]'
25      field.0 = 4
26      Call CurlSetopt curl, 'HTTPPOSTFIELDS', 'field.'
27      Call CurlSetopt curl, 'OUTSTEM', 'response.', '0A'x
28
29      Call CurlSetopt curl, 'URL', site
30      If curlerror.intcode \= 0 Then Call Abort 'Error setting URL option'
31
32      Call CurlPerform curl
33      If curlerror.intcode \= 0 Then Call Abort 'Error POSTing to' site
34      /*
35       * Check that the submission worked
36       */
37      ok = 0
38      Do i = 1 To response.0
39         Say response.i
40      End
41      /*
42       * Cleanup the connection
43       */
44      Call CurlCLeanup curl
45   End
46Call CurlDropFuncs 'UNLOAD'
47Return 0
48
49Abort: Procedure Expose curlerror.
50Parse Arg msg
51Say msg
52If curlerror.curlcode \= 0 Then Say 'cURL error:' curlerror.curlcode '-' curlerror.curlerrm
53Else Say 'RexxCURL error:' curlerror.intcode '-' curlerror.interrm
54Call CurlCLeanup curl
55Call CurlDropFuncs 'UNLOAD'
56Exit 1
57