Perl
This example uses the Chilkat Perl module - https://www.chilkatsoft.com/perl.asp

GET request

1
use chilkat();
2
3
# unlock the chilkat library
4
$global = chilkat::CkGlobal->new();
5
$global->UnlockBundle('UNLOCK CODE');
6
7
# initialize the oauth1 details
8
$oauth1 = chilkat::CkOAuth1->new();
9
$oauth1->put_ConsumerKey("PROVIDEDKEYHERE");
10
$oauth1->put_ConsumerSecret("PROVIDEDSECRETHERE");
11
$oauth1->put_SignatureMethod("HMAC-SHA1");
12
$oauth1->put_OauthUrl("https://yourwhitelabel.cloudfrontend.net/api/v2/sites/");
13
$oauth1->put_OauthMethod("GET");
14
$oauth1->GenNonce(32);
15
16
# initialize rest client
17
$rest = chilkat::CkRest->new();
18
$bUseQueryParams = 1;
19
$rest->SetAuthOAuth1($oauth1, $bUseQueryParams);
20
$rest->AddHeader("Content-Type","application/json; charset=UTF-8");
21
$success = $rest->Connect("yourwhitelabel.cloudfrontend.net", 443, 1, 1);
22
23
# make request
24
$responseJson = $rest->fullRequestNoBody("GET", "/api/v2/sites/");
25
26
# output response
27
print $rest->get_ResponseStatusCode() . "\r\n";
28
print $responseJson . "\r\n";
Copied!

POST request

1
use chilkat();
2
3
# unlock the chilkat library
4
$global = chilkat::CkGlobal->new();
5
$global->UnlockBundle('UNLOCK CODE');
6
7
# initialize the oauth1 details
8
$oauth1 = chilkat::CkOAuth1->new();
9
$oauth1->put_ConsumerKey("PROVIDEDKEYHERE");
10
$oauth1->put_ConsumerSecret("PROVIDEDSECRETHERE");
11
$oauth1->put_SignatureMethod("HMAC-SHA1");
12
$oauth1->put_OauthUrl("https://yourwhitelabel.cloudfrontend.net/api/v2/sites/");
13
$oauth1->put_OauthMethod("POST");
14
$oauth1->GenNonce(32);
15
16
# initialize rest client
17
$rest = chilkat::CkRest->new();
18
$bUseQueryParams = 1;
19
$rest->SetAuthOAuth1($oauth1, $bUseQueryParams);
20
$rest->AddHeader("Content-Type","application/json; charset=UTF-8");
21
$success = $rest->Connect("yourwhitelabel.cloudfrontend.net", 443, 1, 1);
22
23
# prepare json body
24
$jsonReqBody = chilkat::CkJsonObject->new();
25
$success = $jsonReqBody->AddStringAt(-1, "title", "Example Site");
26
$success = $jsonReqBody->AddStringAt(-1, "formatted_domain", "somesite.yourdomain.com");
27
print $jsonReqBody->emit() . "\r\n";
28
29
# make request
30
$responseJson = $rest->fullRequestString("POST", "/api/v2/sites/", $jsonReqBody->emit());
31
32
# output response
33
print $rest->get_ResponseStatusCode() . "\r\n";
34
print $rest->lastErrorText() . "\r\n";
35
print $responseJson . "\r\n";
36
Copied!
Last modified 2yr ago
Copy link