PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a script I use for sending SMS messages through clickatell which was working fine but since I have moved to a different host server it does not work. This is on a Virtual host so I do not have access to change any setteing and they are quite security concious, so I doubt the will make any changes to php.ini
The problem seems to be with file command. The message I get is:
<?php
if($smssend =="Yes")
{
if ($suser_mobile == "")
{"";}
else{
$suser_mobile = str_replace(" ","",$suser_mobile);
$baseurl ="http://api.clickatell.com";
$text = urlencode("New iTouch Job. Job $job_id has been created and assigned to you please log on to the iTouch Support Website to check details");
// auth call
$url1 = "$baseurl/http/auth?user=$smsuser&password=$smspassword&api_id=$smsapi_id";
// do auth call prblem line
$ret = file($url1);
// split our response. return string is on first line of the data returned
$sess = split(":",$ret[0]);
if ($sess[0] == "OK") {
$sess_id = trim($sess[1]); // remove any whitespace
$url2 = "$baseurl/http/sendmsg?session_id=$sess_id&to=$suser_mobile&text=$text";
// do sendmsg call problem line 2
$ret = file($url2);
$send = split(":",$ret[0]);
if ($send[0] == "ID")
echo "success<br>message ID: ". $send[1];
else
echo "send message failed";
} else {
echo "SMS Authentication failure: ". $ret[0];
exit();
}
}
}
else
{"";}
?>
if sockets are enabled, yes. Again phpinfo() will tell you.
You might want to check http://snoopy.sourceforge.net before coding your own http-function...
Sockets are disabled as well. My ISP are super security concious, so I doubt they will let me enable any of those features, I can't even get to my database without using thier web interface(which is pants).
Luckily I found that clickatel have a page you can post to, so you can send sms messages. it means Ihave to open a new window, but I suppose it act's as a confirmation that the message has been sent, which I did'nt have in the previous script. so the code ended up being as follows:
<?php
if($smssend =="Yes")
{
if ($suser_mobile == "")
{"";}
else{
$suser_mobile = str_replace(" ","",$suser_mobile);
$text = urlencode("New iTouch Job. Job $job_id has been created and assigned to you please log on to the iTouch Support Website to check details");
echo "<body onload="java script:window.open('http://api.clickatell.com/http/sendmsg?api_id=$smsapi_id&user=$smsuser
&password=$smspassword&to=$suser_mobile&text=$text
&from=iTouch','new_win','width=300, height=200, resizable=yes')";>";
}
}
else
{"";}
?>