Curl and Sending query string to SMPP server – PHP

  php

Q(Question):

Hi,

I am trying to send some querysting using cURL. This is the working
API

http://smpp4.routesms.com:8080/bulks…ge=testmessage.

The infomation given by Routesms.com:

Port: 2345
Server: SMPPHTTP

This is my code:

$ch = curl_init();
$url = "http://smpp4.routesms.com:8080/bulksms/bulksms?
username=xxxxxx&password=xxxxxxx&type=0&dlr=0&dest ination=94xxxxxxxxx&source=testing&message=testmes sage";
curl_setopt($ch,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($ch);
if(!$result){
echo "Failed<br>";
}

Following results are expected.

1701 = Success
1702 = Invalid URL Error
1703 = Invalid value in username or password field
1704 = Invalid value in "type" field
1705 = Invalid Message
1706 = Invalid Destination
1707 = Invalid Source (Sender)
1708 = Invalid value for "DLR" field
1709 = User validation failed
1710 = Internal Error
1025 = Insufficient Credit

Bu nothing is coming other than Failed.

Pls help me. Thank you in advance.

Lakmarket

A(Answer):

lakmarket wrote:

Hi,

I am trying to send some querysting using cURL. This is the working
API

http://smpp4.routesms.com:8080/bulks…ge=testmessage.

The infomation given by Routesms.com:

Port: 2345
Server: SMPPHTTP

This is my code:

$ch = curl_init();
$url = "http://smpp4.routesms.com:8080/bulksms/bulksms?
username=xxxxxx&password=xxxxxxx&type=0&dlr=0&dest ination=94xxxxxxxxx&source=testing&message=testmes sage";
curl_setopt($ch,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($ch);
if(!$result){
echo "Failed<br>";
}

Following results are expected.

1701 = Success
1702 = Invalid URL Error
1703 = Invalid value in username or password field
1704 = Invalid value in "type" field
1705 = Invalid Message
1706 = Invalid Destination
1707 = Invalid Source (Sender)
1708 = Invalid value for "DLR" field
1709 = User validation failed
1710 = Internal Error
1025 = Insufficient Credit

Bu nothing is coming other than Failed.

Pls help me. Thank you in advance.

Lakmarket

What does curl_error() show?


==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

A(Answer):

On Nov 15, 1:17*pm, Jerry Stuckle <jstuck…@attglobal.netwrote:

lakmarket wrote:

Hi,

I am trying to *send some querysting *using cURL. This is the working
API

http://smpp4.routesms.com:8080/bulks…=xxxxxxx&passw…..

The infomation given by Routesms.com:

Port: 2345
Server: SMPPHTTP

This is my code:

$ch = curl_init();
$url = "http://smpp4.routesms.com:8080/bulksms/bulksms?
username=xxxxxx&password=xxxxxxx&type=0&dlr=0&dest ination=94xxxxxxxxx&source=testing&message=testmes sage";
curl_setopt($ch,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($ch);
if(!$result){
echo "Failed<br>";
}

Following results are expected.

*1701 = Success
*1702 = Invalid URL Error
*1703 = Invalid value in username or password field
*1704 = Invalid value in "type" field
*1705 = Invalid Message
*1706 = Invalid Destination
*1707 = Invalid Source (Sender)
*1708 = Invalid value for "DLR" field
*1709 = User validation failed
*1710 = Internal Error
*1025 = Insufficient Credit

Bu nothing is coming other than Failed.

Pls help me. * Thank you in advance.

*Lakmarket

What does curl_error() show?


==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck…@attglobal.net
==================

The only message display on the screen is "Failed". Do I have to
insert curl_error() somewhere in the code?
Thank you

A(Answer):

On Nov 15, 6:37 am, lakmarket <lakmar…@gmail.comwrote:

On Nov 15, 1:17 pm, Jerry Stuckle <jstuck…@attglobal.netwrote:

lakmarket wrote:

Hi,

I am trying to send some querysting using cURL. This is the working
API

>http://smpp4.routesms.com:8080/bulks…=xxxxxxx&passw….

The infomation given by Routesms.com:

Port: 2345
Server: SMPPHTTP

This is my code:

$ch = curl_init();
$url = "http://smpp4.routesms.com:8080/bulksms/bulksms?
username=xxxxxx&password=xxxxxxx&type=0&dlr=0&dest ination=94xxxxxxxxx&source=testing&message=testmes sage";
curl_setopt($ch,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($ch);
if(!$result){
echo "Failed<br>";
}

Following results are expected.

1701 = Success
1702 = Invalid URL Error
1703 = Invalid value in username or password field
1704 = Invalid value in "type" field
1705 = Invalid Message
1706 = Invalid Destination
1707 = Invalid Source (Sender)
1708 = Invalid value for "DLR" field
1709 = User validation failed
1710 = Internal Error
1025 = Insufficient Credit

Bu nothing is coming other than Failed.

Pls help me. Thank you in advance.

Lakmarket

What does curl_error() show?


==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck…@attglobal.net
==================

The only message display on the screen is "Failed". Do I have to
insert curl_error() somewhere in the code?

Thank you

No, when you incurr curl_error() you will get what curl is saying is
wrong.

A(Answer):

On Nov 15, 5:24*pm, Michael Gooden <m…@michael-gooden.infowrote:

On Nov 15, 6:37 am, lakmarket <lakmar…@gmail.comwrote:

On Nov 15, 1:17 pm, Jerry Stuckle <jstuck…@attglobal.netwrote:

lakmarket wrote:
Hi,

I am trying to *send some querysting *using cURL. This is the working
API

http://smpp4.routesms.com:8080/bulks…=xxxxxxx&passw….

The infomation given by Routesms.com:

Port: 2345
Server: SMPPHTTP

This is my code:

$ch = curl_init();
$url = "http://smpp4.routesms.com:8080/bulksms/bulksms?
username=xxxxxx&password=xxxxxxx&type=0&dlr=0&dest ination=94xxxxxxxxx&source=testing&message=testmes sage";
curl_setopt($ch,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($ch);
if(!$result){
echo "Failed<br>";
}

Following results are expected.

*1701 = Success
*1702 = Invalid URL Error
*1703 = Invalid value in username or password field
*1704 = Invalid value in "type" field
*1705 = Invalid Message
*1706 = Invalid Destination
*1707 = Invalid Source (Sender)
*1708 = Invalid value for "DLR" field
*1709 = User validation failed
*1710 = Internal Error
*1025 = Insufficient Credit

Bu nothing is coming other than Failed.

Pls help me. * Thank you in advance.

*Lakmarket

What does curl_error() show?


==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck…@attglobal.net
==================

The only message display on the screen is "Failed". Do I have to
insert curl_error() somewhere in the code?

Thank you

No, when you incurr curl_error() you will get what curl is saying is
wrong.

Thanks for the information

curl_error() message is: No URL set!

If somebody willing to help I can email the test account username and
password.

Regards,

Lakmarket

A(Answer):

Hi,

I did some corrections of the program.

$url = "http://smpp4.routesms.com:8080/bulksms/bulksms?
username=xxxxxxx&password=xxxxx&type=0&dlr=0&desti nation=xxxxxx&source=xxxxxx&message=testscriptold" ;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(!curl_exec($ch))
{
echo ‘Curl error: ‘ . curl_error($ch);
}
else
{
echo ‘Operation completed without any errors’;
}

Now the output is Curl error: couldn’t connect to host

Thanks

A(Answer):

lankansoft wrote:

Hi,

I did some corrections of the program.

$url = "http://smpp4.routesms.com:8080/bulksms/bulksms?
username=xxxxxxx&password=xxxxx&type=0&dlr=0&desti nation=xxxxxx&source=xxxxxx&message=testscriptold" ;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

if(!curl_exec($ch))
{
echo ‘Curl error: ‘ . curl_error($ch);
}
else
{
echo ‘Operation completed without any errors’;
}

Now the output is Curl error: couldn’t connect to host

Thanks

That’s because "http://smpp4.routesms.com:8080/bulksms/bulksms?
username=xxxxxxx&password=xxxxx&type=0&dlr=0&desti nation=xxxxxx&source=xxxxxx&message=testscriptold" ;

is not a URL. It is a URL and a query parameter list.

Only the URL is passed in CURLOPT_URL. The parameter list is passed in
CURLOPT_POSTFIELDS.

I’d recommend you google for a CURL tutorial. It will help you a lot.


==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

LEAVE A COMMENT