Created
March 30, 2016 06:04
-
-
Save MadcapJake/f47f2c0f45ac4473a436b4a4f62bdb9b to your computer and use it in GitHub Desktop.
Create RT ticket in Perl 6 with Net::Curl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
use Net::Curl::NativeCall; | |
with curl_easy_init() { | |
# curl_easy_setopt($_, CURLOPT_COOKIESESSION, +True); | |
my Str $body; | |
my $login = 'user=guest&pass=guest'; | |
curl_easy_setopt($_, CURLOPT_URL, 'https://demo.bestpractical.com/REST/1.0/'); | |
curl_easy_setopt($_, CURLOPT_COPYPOSTFIELDS, $login); | |
curl_easy_setopt($_, CURLOPT_WRITEDATA, $body); | |
my $res = curl_easy_perform($_); | |
if $res != CURLE_OK { | |
warn sprintf("curl_easy_perform failed: %s\n", curl_easy_strerror($res)) | |
} else { | |
say $body; | |
} | |
curl_easy_setopt($_, CURLOPT_URL, 'https://rt.perl.org/REST/1.0/'); | |
my $ticket = qq:to/RT/; | |
id: ticket/new | |
Queue: General | |
Requestor: [email protected] | |
Subject: Testing a submitter function | |
Text: Here is where you would place all sorts of details about | |
the issue as well as anything else you feel might be important | |
Thanks! | |
RT | |
curl_easy_setopt($_, CURLOPT_COPYPOSTFIELDS, "$login\&content=$ticket"); | |
curl_easy_setopt($_, CURLOPT_WRITEDATA, $body); | |
$res = curl_easy_perform($_); | |
if $res != CURLE_OK { | |
warn sprintf("curl_easy_perform failed: %s\n", curl_easy_strerror($res)) | |
} else { | |
say $body; | |
} | |
curl_easy_cleanup($_) | |
} else { warn "curl failed to initialize" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment