Page 2 of 2

Re: CURL gives 505

Posted: Fri Sep 18, 2009 12:00 am
by malaiselvan
Hi neelu7779,

Have you solved the problem?

I bought a package from mysmsmantra and I am trying to call via cURL from my PHP website.
Can you share your code block with me malaiselvan@gmail.com.

Thanks & Regards
Malai

Re: CURL gives 505

Posted: Fri Sep 18, 2009 9:03 am
by neelu7779
I can not share code with you as it is for an enterprise application.

However, I will assist you if you have any problems.

Let me know..

Regards
Neelesh Tambe

Re: CURL gives 505

Posted: Mon Sep 21, 2009 11:47 pm
by malaiselvan
Thanks for your reply.

Following is the code I used to send SMS.

$cURLhandle = curl_init('http://bulksms.mysmsmantra.com:8080/Web ... 9444997901');
$fp = fopen("debug.txt","w");
curl_setopt($cURLhandle, CURLOPT_VERBOSE, 1);
curl_setopt ($cURLhandle, CURLOPT_STDERR, $fp);

curl_setopt($cURLhandle, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($cURLhandle, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($cURLhandle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cURLhandle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($cURLhandle, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($cURLhandle);

$result = '<br />'.curl_getinfo($cURLhandle, CURLINFO_HTTP_CODE).'<br />';
$result .= '<br />'.curl_getinfo($cURLhandle, CURLINFO_EFFECTIVE_URL);
$result .= '<br />'.curl_error($cURLhandle);
curl_close($cURLhandle);

In the debug.txt Iam getting the following error. Could you help me where I am standing wrong?

============
* About to connect() to bulksms.mysmsmantra.com port 8080 (#0)
* Trying 216.154.213.157... * Timeout
* connect() timed out!
* Closing connection #0
============

Regards
Malai

Re: CURL gives 505

Posted: Tue Sep 22, 2009 1:13 am
by neelu7779
hi,

Are you using a shared host? or this is a owned server?

Re: CURL gives 505

Posted: Tue Sep 22, 2009 1:22 am
by neelu7779
May be the port 8080 on your server is blocked.

First try unblocking the port 8080. Then retry.

let me know if that works or not..

Take care.
Regards
Neelesh Tambe

Re: CURL gives 505

Posted: Tue Sep 22, 2009 3:23 am
by malaiselvan
We are using shared hosting from hostmonster

I sent out an E-mail to their support guys. I will let you know once I get the reply from them.

Re: CURL gives 505

Posted: Tue Sep 22, 2009 1:47 pm
by malaiselvan
Hostmonster said that the port 8080 is blocked in shared webhosting :( :cry:

I check with smsmantra and they provided the following URL

Code: Select all

http://smscgateway.com/messageapi.asp?u ... sage=Hello World
I try to configure the above API using the below code

Code: Select all

   $mobilenumber = '9444997901';
    $message = 'Hello World';
    $curlPost = 'username=gleeads&password=xxxxxx&sender=GLEEADS&mobile=' . urlencode($mobilenumber) . '&message=' . urlencode($message);
    $fp = fopen("debug.txt","w");
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt ($ch, CURLOPT_STDERR, $fp);
 
    curl_setopt($ch, CURLOPT_URL, 'http://smscgateway.com/messageapi.asp');
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
And the log file says

Code: Select all

* About to connect() to smscgateway.com port 80 (#0)
*   Trying 75.125.154.74... * connected
* Connected to smscgateway.com (75.125.154.74) port 80 (#0)
> POST /messageapi.asp HTTP/1.1
Host: smscgateway.com
Accept: */*
Content-Length: 227
Content-Type: application/x-www-form-urlencoded
 
< HTTP/1.1 200 OK
< Date: Tue, 22 Sep 2009 18:44:59 GMT
< Server: Microsoft-IIS/6.0
< X-Powered-By: ASP.NET
< Content-Length: 28
< Content-Type: text/html
< Set-Cookie: ASPSESSIONIDACCADBCR=IDOIPPODHLPNPAELBAFNDLEC; path=/
< Cache-control: private
< 
* Connection #0 to host smscgateway.com left intact
* Closing connection #0
 
But SMS not sent.

Do you find anything I missing here?

Regards
Malai

Re: CURL gives 505

Posted: Wed Sep 23, 2009 12:16 am
by neelu7779
hi,

First thing, check the TLD. it has to be ".co.in" not ".com".

I suggest you print the url on the just before sending the sms. Copy the url and paste it in a new browser tab. If the URL is correct you should receive the SMS.

If you are sure about the url, then check with the mysmsmantra support and tell them about the delay. may be delay is because of the DND entry.

regards
Neelesh Tambe

Re: CURL gives 505

Posted: Wed Sep 23, 2009 3:47 am
by malaiselvan
Hi Neelu, thanks for your support. The following code block solves my problem.

Code: Select all

   $ch = curl_init();
    $url = 'http://smscgateway.com/messageapi.asp?username=yyyyyy&password=xxxxxx&sender=' . urlencode($sender) . '&mobile=' . urlencode($mobilenumber) . '&message=' . urlencode($message);
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $contents = curl_exec ($ch);
    $result = curl_errno($ch);
    curl_close ($ch);