CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Curl SMS

 



Demerzel
Novice

Jun 3, 2011, 6:07 AM

Post #1 of 5 (1058 views)
Curl SMS Can't Post

I would like to send SMS using Curl. I have a similar example in PHP but I it is confusing.
I have this

Code
my $url ='http://api/send.php'; 
my $postfields ="DE_LS_IP_ATTM_USER_NAME=testcsr&DE_LS_IP_ATM_USER_PASSW=pass&DE_WEB_COMMAND=login"; print "Testing curl version",WWW::Curl::Easy::version(),"\n";
my $curl= WWW::Curl::Easy->new()
$curl->setopt(CURLOPT_URL, $url);
$curl->setopt(CURLOPT_RETURNTRANSFER, 1);
$curl->setopt(CURLOPT_POST, 1);
$curl->setopt(CURL_POSTFIELDS, $postfields);
$curl->setopt(CURLOPT_TIMEOUT, 10);

Where is place for recipient phone number? How to insert my message?
Maybe someone have good working example?


Demerzel
Novice

Jun 6, 2011, 3:26 PM

Post #2 of 5 (1043 views)
Re: [Demerzel] Curl SMS [In reply to] Can't Post

I was able to move forward a little

Code
my $postfields =':user=s&pass=S&number=324&text=dfgdfgdf&from=8';  
my $curl= WWW::Curl::Easy->new();
$curl->setopt(CURLOPT_URL, $url);
$curl->setopt(CURLOPT_RETURNTRANSFER, 1);
$curl->setopt(CURLOPT_POST, 1);
$curl->setopt(CURL_POSTFIELDS, $postfields);
$curl->setopt(CURLOPT_TIMEOUT, 10);

my $retcode = $curl->perform;
$curl->urlencode();
print $curl->strerror($retcode);

But I get error

Code
Argument "CURL_POSTFIELDS" isn't numeric in subroutine entry at 
./script.pl line 283 (#2)
Argument ":user=s&pass=S&number=3&text=d..." isn't
numeric in subroutine entry at ./script.pl line 283 (#2)
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>413 Request Entity Too Large</title>
</head><body>
<h1>Request Entity Too Large</h1>
The requested resource<br />/ble.php<br />
does not allow request data with POST requests, or the amount of data provided in
the request exceeds the capacity limit.
</body></html>
Status: 001, Id: "longid..........", Number:
No error7



(This post was edited by Demerzel on Jun 6, 2011, 3:28 PM)


miller
User

Jun 6, 2011, 3:57 PM

Post #3 of 5 (1039 views)
Re: [Demerzel] Curl SMS [In reply to] Can't Post

Why are you using WWW::Curl in the first place? Is it just because you found a php example that used it?

I suggest that you use LWP, or WWW::Mechanize if you're doing more complex form posts.

- Miller


Demerzel
Novice

Jun 7, 2011, 2:42 AM

Post #4 of 5 (1035 views)
Re: [miller] Curl SMS [In reply to] Can't Post

Why Curl? Basically because I have an example php. This is one of the websites running on the server on which the script will go ...
I will look at these suggestions. Probably more support will be needed.
Thanks for now.


miller
User

Jun 7, 2011, 9:22 AM

Post #5 of 5 (1023 views)
Re: [Demerzel] Curl SMS [In reply to] Can't Post

Well, since this is perl and not php, I suggest you use the resources I linked to. I believe they'll be much better for you in the end. Come back if you run into any problems.

- Miller

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives