YOU MUST REGISTER AN ACCOUNT WITH SMS NOTIFY GHANA BEFORE YOU CAN GET
YOUR UNIQUE_API_KEY. THANK YOU
An api key associated with number you will used during registration will be generated for you.
Below are the details
API KEY
YOUR_API_KEY
d=xxxxx
Error Codes:
1000
= Message submited successful
1002
= SMS sending failed
1003
= insufficient balance
1004
= invalid API key
1005
= invalid Phone Number
1006
= invalid Sender ID. Sender ID must not be more than 11 Characters. Characters
include white space.
1007
= Message scheduled for later delivery
1008
= Empty Message
For further assistance call SmsNotifygh on 0205851692
Thanks.
Below are sample codes in PHP,Java and Python on how
to use our API
PHP
$key="YOUR_API_KEY" //your unique API key;
$message=urlencode($message) //encode url;
/*******************API URL FOR SENDING MESSAGES********/
$url="http://sms.smsnotifygh.com/smsapi?key=$key&to=$phone&msg=$message&se
nder_id=$sender_id";
/****************API URL TO CHECK BALANCE****************/
$url="http://sms.smsnotifygh.com/api/smsapibalance?key=$key";
$result=file_get_contents($url); //call url and store result;
switch($result){
case "1000":
echo "Message sent";
break;
case "1002":
echo "Message not sent";
break;
case "1003":
echo "You don't have enough balance";
break;
case "1004":
echo "Invalid API Key";
break;
case "1005":
echo "Phone number not valid";
break;
case "1006":
echo "Invalid Sender ID";
break;
case "1008":
echo "Empty message";
break;
}
JAVA
import java.net.*;
import java.io.*;
/**
* @author SmsNotifygh
*/
public class SendMessage {
public static void main(String[] args) throws Exception {
String API_key = "YOUR_API_KEY";
String message = "Sending SMS has never been this fun!";
String phone_number = "02xxxxxxxx";
String sender_id = "xxxxxxxxxx"; //11 characters
/*******************API URL FOR SENDING MESSAGES********/
URL url = new URL("http://sms.smsnotifygh.com/smsapi?key=" + API_key + "&to="
+ phone_number + "&msg=" + message + "&sender_id=" + sender_id);
/****************API URL TO CHECK BALANCE****************/
URL url = new URL("http://sms.smsnotifygh.com/api/smsapibalance?key=" + API_ke
y);
URLConnection connection = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInp
utStream()));
String inputLine;
inputLine = in.readLine().trim();
if (inputLine.equals("1000")) {
System.out.println("Message sent");
} else if (inputLine.equals("1002")) {
System.out.println("Message not sent");
} else if (inputLine.equals("1003")) {
System.out.println("You don't have enough balance");
} else if (inputLine.equals("1004")) {
System.out.println("Invalid API Key");
} else if (inputLine.equals("1005")) {
System.out.println("Phone number not valid");
} else if (inputLine.equals("1006")) {
System.out.println("Invalid Sender ID");
} else if (inputLine.equals("1008")) {
System.out.println("Empty message");
}
in.close();
}
}
PYTHON
#!/usr/bin/env python
import urllib2
import urllib
def send_sms(api_key,phone,message,sender_id):
#parameters to send SMS
params = {"key":api_key,"to":phone,"msg":message,"sender_id":sender_id}
#url to send SMS
/*******************API URL FOR SENDING MESSAGES********/
/****************API URL TO CHECK BALANCE****************/
content = urllib2.urlopen(url).read()
#Interpreting codes obtained from reading the URL
if(content.strip() == '1000') :
print "Message successfully sent"
elif(content.strip() == '1002') :
print "Message not sent"
elif(content.strip() == '1003') :
print "Your balance is not enough"
elif(content.strip() == '1004') :
print "Invalid API Key"
elif(content.strip() == '1005') :
print "Phone number not valid"
elif(content.strip() == '1006') :
print "Invalid sender id"
elif(content.strip() == '1008') :
print "Empty message"
#Defining variables to be used inside function
api_key = 'YOUR_API_KEY' #API Key generated from your smsnotify account
phone = '02xxxxxx' #SMS recepient's phone number
message = 'xxxxxxxxxxxxxxxxxxxxx' #Message to be sent
sender_id = 'xxxxxxxxxxxx' #Sender id for the message
#Calling function that was created to send sms
send_sms(api_key,phone,message,sender_id)