Developers


Joy Of Text Pro Plugin Functions

The Joy Of Text Pro plugin exposes a number of functions, which you can use to integrate with your existing plugins.

Send SMS messages

You can send SMS messages from your plugin by calling the following JOT function:

$return = Joy_Of_Text_Plugin()->currentsmsprovider->send_smsmessage($number, $your_message, $optional_senderid);

Parameters:
$number – the number you wish to send a message to

$your_message – your message

$optional_senderid – an optional parameter, allowing you to specify a Sender ID

 

$return is an array containing status data about the message, for example:

$return['send_message_errorcode']

 

Send MMS messages

$return = Joy_Of_Text_Plugin()->currentsmsprovider->;send_mmsmessage($number, $your_message, $mms_imageid, $optional_senderid)

Parameters:
$number – the number you wish to send a message to

$your_message – your message

$mms_imageid – corresponds to the id of an image in your WordPress Media Library.

$optional_senderid – an optional parameter, allowing you to specify a Sender ID

 

$return is an array containing status data about the message, for example:

$return['send_message_errorcode']

 

Send text-to-voice messages

$return = Joy_Of_Text_Plugin()->currentsmsprovider->send_callmessage($number, $your_message, $audio_id, $optional_senderid)

Parameters:
$number – the number you wish to send a message to

$your_message – your message

$audio_id – corresponds to the id of an audio in your WordPress Media Library.

$optional_senderid – an optional parameter, allowing you to specify a Sender ID

 

$return is an array containing status data about the message, for example:

$return['send_message_errorcode']

 

 

Phone Number verification

This function sends $number to Twilio. If it’s a valid number, $return will contain the full internationally formatted number. If $number is not a valid phone number, then $return will be blank (“”).

$return = Joy_Of_Text_Plugin()->currentsmsprovider->verify_number($number);

Parameters:
$number – the number you wish to send a message to.

 

Add a member to a group

This function will add a new member to an existing JOT group.

$return = Joy_Of_Text_Plugin()->options->process_add_member($member_name, $member_phone_number, $JOT_group_id, $optional_member_details)

Use the $optional_member_details if you want to add any or all of the following additional member data:

  • Email address. Use $optional_member_details[‘jot_grpmememail’]. e.g.  $optional_member_details[‘jot_grpmememail’] = “jotplugin@gmail.com”
  • Member address. Use $optional_member_details[‘jot_grpmemaddress’] e.g. $optional_member_details[‘jot_grpmemaddress’] = ‘Fifth Avenue’
  • Member city.  Use $optional_member_details[‘jot_grpmemcity’] e.g. $optional_member_details[‘jot_grpmemcity’] = ‘New York’
  • Member state. Use $optional_member_details[‘jot_grpmemstate’] e.g. $optional_member_details[‘jot_grpmemstate’] = ‘New York’
  • Member zip. Use $optional_member_details[‘jot_grpmemzip’] e.g. $optional_member_details[‘jot_grpmemzip’]  = ‘10020’

$return will be an array containing the following keys:

array('errormsg' , 'errorcode', 'errorfield', 'verified_number' );

 

Schedule a message

This function requires the Pro plugin and Joy Of Text Scheduler extension. The function will schedule a single message to be sent a future date and time.

The format of the function is:

jot_scheduler()->add_schedule($member_number, $schedule_description,$message, $message_type, $schedule_timestamp, $optional_sched_args )

where:

  • $member_number = the phone number you wish to send the message to.
  • $schedule_description = a text description of the schedule.
  • $message = the message to be sent.
  • $message_type = either ‘sms’, ‘mms’ or ‘call’, where call is a text-to-voice or audio file call.
  • $schedule timestamp = the date and time when you’d like the message to be sent. The format of the timestamp is yyyy-mm-dd hh:mm:ss
  • $optional_sched_args are an optional parameter.
    • For MMS and call messages, use $optional_sched_args[‘media_id’] to specify the id of a media file residing in your Media Library.
    • To specify an alphanumeric Sender ID, use $optional_sched_args[‘sender_id’]. Not supported by Twilio in the USA.

For example,

jot_scheduler()->add_schedule("+447700543900","Message for Christmas day" ,"Hi Dave, Merry Christmas","sms", "2018-12-25 09:00:00");