<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
if (isset($_POST["submit"])) {
This turns on errors for displaying and that way they might show up on your page. Some times will not.
If it is a Curl error, you can display them, but, I added some code in it for that.
Are you getting ANY displays when you run this?
astoncipher: It is a server that was loaded from a Vicibox ISO 8.1.2, so the OS should be OpenSUSE 13.1. The system is a webserver/dialing platform with all the trimmings it needs to run this script no problem.
Also if you need access to the server I am willing to grant you root for a small period of time for you to troubleshoot with me if possible. My phone number is 813-481-3879… Yesterday the site only let me reply so many times before I had to wait 5 hours to reply and that really cut down on my productivity lol
I have done all instructions, still no errors displayed unless I make an error in entering code and try to reload the page - Then it does go to the /var/log folder.
Still no output at all when send_now is pressed. Not sure what’s going on, but it doesn’t even appear to be running the script to send a text at all. Any other info or help? Below I will post the scriptsThird Rock Telecom gives for Send/Receive SMS
Send:
Overview
The ability to send and receive SMS and MMS messages. Your DID to a cell phone and vice versa. All just a web call away.
Restrictions
SMS is intended for enhancing person to person communication. You may not send more than 1 message per second per phone number and no more than 3,000 messages per day per number. You are also not to spam the same message to multiple people.
Sending spam or many automated messages will result in immediate SMS suspension.
Controller: /sms or /mms
Full Url: https://sms.teleapi.net/sms/NOTE: The URL here is different than a lot of the rest of the API
Content-Type: application/x-www-form-urlencoded
Encoding: UTF-8
Functions
/sms/send
/mms/send
/sms/send
Full Url: https://sms.teleapi.net/sms/send
Arguments:
token (string, required)
source (int, required)
destination (int, required)
message (string, required)
Info: source must be a number from your inventory. Basically, you’re saying “Send an SMS from this number to that (10 digit) number. Here’s the message”.
Info: source must be a number from your inventory. file_data needs to be a base 64 encoded string of your file’s contents. Alternatively, if you already have a URL for the image you can simply send us that url in file_url . We’ll grab it and do the rest for you. Ultimately, though, we need file_name and file_data OR file_url. Your choice.
In order to receive SMS or MMS messages we need somewhere to send them. In your “My Settings” page in the user portal, there is a settings for “Incoming SMS Post URL”. All messages that come to any of your phone numbers will get sent to this URL via HTTP POST. So, all you need is a script that will consume these web calls and do something with it.
$source = $_POST['source'];
$destination = $_POST['destination'];
$message = $_POST['message'];
//save to a csv file... if you're into that sort of thing
$csv_line = sprintf('%s,%s,%s', $source, $destination, $message);
file_put_contents('/path/to/awful_csv_log.csv', $csv_line);
//make it show up in apache's error log
error_log(print_r($_POST, true));
//I've gone to Cancun and "acccidentally" left my phone at home
$ch = curl_init('https://sms.teleapi.net/sms/send');
$data = array(
'token' => $my_api_token,
'source' => $destination,
'destination' => $source,
'message' => 'Hello. I am unavailable right now. Please leave a brief message and I will get back to you when I'm sober.'
);
$data = http_build_query($data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/x-www-form-urlencoded',
'Content-Length: ' . strlen($data)
));
$resp = curl_exec($ch);
curl_close($ch);
$resp = json_decode($resp);
if ($resp->code == 200) {
//the boss is mad
} else {
//the boss is still mad. but he didn't get a snarky message
}
Delivery Notifications
Delivery Notifications are only supported via our API and SMPP connections. We don’t support delivery notifications via Jabber/XMPP or Slack.
Let me preface this by saying delivery notifications are not always a sure thing. In order for delivery notifications to work every hop along the way, from here to the end number, has to send them. Sometimes they don’t. Also, sometimes you won’t get a delivery notification for quite a while. It all depends on many variables from here to there. That said, they can be very nice in letting you know how successful your SMS message was. They are also asynchronous. This means that sending the message is a separate process from knowing if the message is delivered or not, which is why this is a separate web call to look for.
Breakdown of the delivery notification process:
You give us a message to send to some end number
The API call that you made to us to send the SMS message ends, in the response is an ID that we will refer to when we deliver the notification
We pass that message along to carriers
Carriers may pass to other carriers
Message gets delivered to device, or is rejected, fails, etc
A notification is passed back down the chain of carriers, one by one, with the status of the message
The notification finally makes it back to us
We grab your SMS Delivery Notification URL and, finally, pass that notification on to you via HTTP POST using the ID we gave you as a reference point
To receive delivery notifications via HTTP POST, simply set an SMS Delivery Notification URL in your My Accounts page in the user portal. Once set, you will receive notifications for all messages sent.
To receive delivery notifications via SMPP, send a registered_delivery value of 1 in your submit_sm command to send the message.
The POST that you get to your server will look something like:
Since all DLR information is relayed from upstream providers and differences in carrier specific response types exist in an unregulated industry, error codes will by varied. Instead of using this information, we suggest looking at the status to determine the cause of an error or send_status for high level checking.
To debug it, you can add this in to display each number it is processing.
// Read one line at a time ( one phone number per line )
while (($phone_number = fgets($numbers_file)) !== false) {
echo "Processing number: " . $phone_number . "<br>";
And, this should show the number it is using for each step. If you do not get any, then the text file is not being opened correctly or is not formatted as a text file with each number on a separate line.
Debugging is a step by step process.
As I was writing this, you posted. I see you already have the send Curl code. All you would need to do then is to add in the file reading code and set your tokens up in that code and it should work. Do you understand how to do this?
After following the steps to have it echo each phone number it’s processing and clicking “send_sms” I still got absolutely no response. The page just stays exactly as it is so I guess it isn’t properly processing the file as you said. The line I have for opening the file reads exactly as is:
$numbers_file = fopen("textfile.txt", "r");
So with that, all I did to make the file is I just typed my number 3 times into notepad like this:
8134813879
8134813879
8134813879
and saved it as a .txt file. The encoding at the bottom says it’s ANSI… Should it be unicode or UTF-8? Did you see anything else I can do to debug?
I put them both in their own folder, both files in the same folder. The file for the webpage is called “smstext.php” and the text file is called “textfile.txt”. Once again they are in their OWN folder together and the folder is named “text”.
create a new file called smstext2.php. Put this code in it and bring it up in a browser.
See if it displays the numbers or not. We need to debug it step by step.
<?php
// Open the text file.
$numbers_file = fopen("textfile.txt", "r");
// Read one line at a time ( one phone number per line )
while (($phone_number = fgets($numbers_file)) !== false) {
echo $phone_number . "<br>";
}
// Close the file
fclose($numbers_file);
?>
Try this version. I was reading your details and this service does not allow more than one call per second and they do not allow sending the same message to large number of phones. Therefore, you might need to add some sort of reference number inside the message so that the message is different each time. Not sure at all on this…
<?php
if (isset($_POST["submit"])) {
// Open the text file. ( HERE YOU WOULD NEED TO CHANGE THE NAME OF THE FILE TO YOUR FILENAME ! ! ! )
$numbers_file = fopen("inputfile.txt", "r");
// Read one line at a time ( one phone number per line )
while (($phone_number = fgets($numbers_file)) !== false) {
// Process the one phone number, create the URL paramenters with info in the correct places
$url_parms = "?token=e9cf7e33-0c00-4eb5-94fb-7ae060fa4329&source=8445972807&destination=" . trim($phone_number) . "&message='This is The National Health Enrollment Center. You are still eligible to enroll in an affordable health insurance plan. Call 844-597-2807 now to speak with a licensed agent.'";
// Using the created URL, send it using Curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://sms.teleapi.net/sms/send");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $url_parms);
// Send message and receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$response = json_decode($response);
if ($response->code == 200) {
echo "SMS sent out to: " . $trim($phone_number) . "<br>";
} else {
echo "ERROR sending SMS to: " . $trim($phone_number) . "<br>";
}
// To not cause issues with the server being overwhelmed, delay one second between SMS' . This might be able to be lowered.
sleep(1);
}
// Close the file
fclose($numbers_file);
}
?>
<!DOCTYPE html>
<html>
<body>
<h1>Send SMS messages to all numbers in text file</h1>
<input type="submit" name="submit" value="send_now" />
</body>
</html>
I changed the error reporting section and also added quotes on your message as I think that might be a problem. Good luck…
It’s still not working. I’m not sure that the “Send Now” button is doing anything… I wonder if we can run this just by taking that button out? Btw it’s not that they it won’t let you send those texts that fast or what have you, it’s that they will stop the account and flag it as spam if you do. We have already spoken with the company and gotten the go ahead though…
Once again, this page has been uploaded to the same folder with all the same options and unfortunately is still not doing anything. No error codes or nothing.
Also, you should probably place all of the PHP code inside of the form area after the input so that it displays the output on the live page. So, all the PHP code would be between the <input tag and the </form tag…
You don’t have to pay, we will solve it for free. I have also been extremely busy. We just need to debug the code to see what it is doing wrong. I can test it from here since you have included your token in the post’s.
I will do so later today as I am working right now. I think we are close. Talk to you a little later in my day.