in reply to Re: Curl usage with Perl's system command
in thread Curl usage with Perl's system command

partial success. Its difficult to correct errors inside strings.

https://api.****/**/*****/messages has to be quoted with '\' and so does api:key***** without which i get a HTTP 400 bad request. found this by checking the original curl string from the company.
when i use it with '' eg '\'api:key-123456etc1234\'' and '\'https://api.****/**/*****/messages\''
i get this message which seems quite documented on stack overflow
Protocol 'https not supported or disabled in libcurl
same for http as well.strange
Protocol 'http not supported or disabled in libcurl
i will try this on the server, maybe it might just work there.
1st update curl-config --protocols shows me that HTTP is supported on my m/c.
so i guess im still in the woods with quoting things in perl :D. thanks for the help sir.
ill find a way out.
2nd update. thanks its working for me. well its just a string thing i goofed up somewhere as revealed in libcurl documentation.ive changed the order of the URL around. For all practical purposes your code was spot on. The only thing i faced is the to name<name@email> for sender address was not being accepted and i actually passed a string there.
But this is just a start. I guess LWP or WWW::Curl will be the right approach i understand.thanks!
for funssake im putting up the working code here. But Loops code is 99.99%% accurate for my use i would say. I hope such situatiosn never arise where i need to take someone elses code :D. Thanks
use strict; use warnings; use Capture::Tiny qw/ capture /; my $message = "first line of text"; $message .= "\nsecond line of text"; my ($to_id, $subject) = qw(ron\@asdfasdf.cc testMessage); my @args = ( '-v', '-s', '--user',"api:key-123456", , 'https://api.XXX.net/v2/xxx.yyy.org/messages', ,'-F', "from='xxx yyy <postmaster\@xxx.yyy.org>", ,'-F', "to=ron\@xxx.cc", ,'-F', "subject=\'$subject\'", ,'-F', "text=\'$message\'"); my ($stdout,$stderr,$exit) = capture { system 'curl', @args; };