Reputation: 692
On localhost sms working
I using curl to hit an api, I tried this method on localhost and its working fine as i want , but when i copied same method to live website it stop working on live website.
$msg ="Some Custom msg here";
$msgencoded = urlencode($msg);
// message is enocded
$numEncode = urlencode($telePhone);
// Telephone is enocded
NOTE :i am getting this variable correctly. $telephone
API as per API document
$url = "http://msg_server_website.com:8080/SMSAPI.jsp?
username=user_name&
password=user_pwd&
sendername=sender_name&
mobileno=".$numEncode."&message=".$msgencoded."";
My curl function which is working on localhost.
$data = $msg;
$crl = curl_init();
curl_setopt($crl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($crl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($crl, CURLOPT_URL, $url);
curl_setopt($crl, CURLOPT_HEADER, 0);
curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($crl, CURLOPT_POST, 1);
curl_setopt($crl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($crl);
if ($response) {
// if curl_exec() returned false and thus failed
echo 'everything was successful';
}
else {
echo 'An error has occurred: ' . curl_error($crl);
}
curl_close($crl);
UPDATE 1:
error has occurred: Failed to connect to websitename.com port 8080: Connection refused
I am trying many times i got this error. what to do in this case.
UPDATE 2
8080 port is blocked on client server. What to do, How to unblock the port.
UPDATE 3 My problem is solved now , as in my case its PORT issue of 8080 which is not free on client host,now ever thing works as expected.
Thank you everyone for support.
Upvotes: 0
Views: 1074
Reputation: 692
Just to close this post, I am posting this as answer.
My problem is solved now , as in my case its PORT issue of 8080 which is not free on client host,now ever thing works as expected.
I checked with the server provider (Godady in this case).As client is using shared hosting so port can not freed for individual person.
so i talked to sms provider and they suggested some changes related to port and my API now run successfully.
Upvotes: 1