0

I created a simple sms app using sms api which is using curl.

integration is pretty straight forward

<?php
$ch = curl_init(http://smsapi.Wire2Air.com/smsadmin/submitsm.aspx');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"VERSION=2.0&userid=[username]&password=[userpassword]&VASId=[VASId]&PROFILEID=[PROFILEID]&FROM=27126&TO=[Mobile Number]&Text=[Text Message]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
Print($data); /* result of SMS API call*/
08 ?>

I have curl ON in my server but the application doesn't work to my server any longer, it used to work before but doesn't work anymore. I uploaded the same php file to my other server, which has the curl ON too and it works there. That is weird that is works to one server and doesn't on the other server.

Here are the curl setting of my server where it doesn't work. And it doesn't echo anything, the request goes quickly without loading. Am I missing something here?

curl

cURL support    enabled
cURL Information    7.19.7
Age 3
Features
AsynchDNS   No
Debug   No
GSS-Negotiate   Yes
IDN Yes
IPv6    Yes
Largefile   Yes
NTLM    Yes
SPNEGO  No
SSL Yes
SSPI    No
krb4    No
libz    Yes
CharConv    No
Protocols   tftp, ftp, telnet, dict, ldap, ldaps, http, file, https, ftps, scp, sftp
Host    x86_64-redhat-linux-gnu
SSL Version NSS/3.14.0.0
ZLib Version    1.2.3
libSSH Version  libssh2/1.4.2

Below are the curl settings of my other server, on which my same sms application works.

curl

cURL support    enabled
cURL Information    7.24.0
Age 3
Features
AsynchDNS   Yes
CharConv    No
Debug   No
GSS-Negotiate   Yes
IDN Yes
IPv6    Yes
krb4    No
Largefile   Yes
libz    Yes
NTLM    Yes
NTLMWB  Yes
SPNEGO  No
SSL Yes
SSPI    No
TLS-SRP No
Protocols   dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp
Host    x86_64-unknown-linux-gnu
SSL Version OpenSSL/1.0.0
ZLib Version    1.2.3
libSSH Version  libssh2/1.2.2

Here it loads and read the request.

cokeman19
  • 2,405
  • 1
  • 25
  • 40
  • first, there is a " missing at "Version" line. second you should escape your text and all user inputs. – recycler Feb 18 '16 at 21:36
  • curl_setopt($ch, CURLOPT_POSTFIELDS,"VERSION=2.0&userid=[username]&password=[userpassword]&VASId=[VASId]&PROFILEID=[PROFILEID]&FROM=27126&TO=[Mobile Number]&Text=[Text Message]"); <-- " is missing – recycler Feb 18 '16 at 21:39
  • you should also check, if $ch is a valid resource, if not, then read the error status – recycler Feb 18 '16 at 21:40
  • i understand the quote missing might be on pasting but the same snippet is working to my other server. –  Feb 18 '16 at 21:41
  • also on the server where it works .. it gives a response back with the JOBID: some random number , but on the other production server it doesn't work and never give any response back. –  Feb 18 '16 at 21:46

1 Answers1

0

you could try the curl request from a terminal, you can add a -v option for more verbose information about what's going on in the request.

or you can do a verbose request from php itself: see Php - Debugging Curl

if it's working from one server and not from the other, there might be an IP filter on the SMS service side, which would not be a strange thing for an SMS service to have.. abuse is very possible :)

Community
  • 1
  • 1
Tommos
  • 820
  • 5
  • 14