Create contact groups on your SMSJuice account that you can send to with the send API.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.smsjuice.com/groups/contacts");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{
"key": "key",
"secret": "secret",
"groupName": "MyExistingGroup",
"contacts": ["447933652246"]
}');
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
<?php
include("../class/ContactGroup.class.php");
include("../TextMessagingService.php");
use TextMessagingService;
//create aninstance of the group that you want to add new contacts to
$group = new ContactGroup($key, $secret, $newGroupName);
//add thew new contact to the group
$group->addContact("447943385586");
//Add the new contact to the group on your SMSJuice account.
echo TextMessagingService::addContactToGroup($group);
?>
| Parameter | Description | Required |
|---|---|---|
| key | account authentication key | Required |
| secret | account authentication secret | Required |
| groupName | Name of existing group to which the new contacts/numbers will be added | Required |
| contacts | contacts to add to the existing group. -You can add contacts with a name and a number OR just the number only. The list can take mixed values (as numbers only and names with numbers) at the same time. |
Required |
{
"status": "success"
"operation": "add contacts to group"
"groupName": "IamAnExistingGroup"
"invalidContacts": []
}
| Success Response | Description |
|---|---|
| status | whether the group creation was a success |
| operation | the operation that was being done. In this case it's 'add contacts to group' |
| groupName | Name of the existing group to which new contacts were added |
| invalidContacts | A list of invalid contacts submitted but not stored as part of the group |
{
"operation": "failed"
"error": "Group 'MyGroupName' does not Exist. Please create a group first."
}
| Error Response | Description |
|---|---|
| invalid_credentials | Invalid API key and/or secret |
| Group Does not exist | Group to add numbers to does not exist on your account |