Page 1 of 1

HESK with SMS API function - script

Posted: Fri Apr 29, 2016 12:07 pm
by trainyoucan
Again, I'm a HESK fan, couple of installations, got this script developed a while ago and constantly need to search for it to update in new HESK updates.

PS: Hopefully I can use my same reference for future update reference

So I got this script developed by a Freelancer a couple of years ago that integrate with HESK and send the client a SMS (Text message) if he log a ticket online, or someone update his details with a valid cellphone number.

Currently using http://www.bulksms.com/ API function to send messages from Hesk.

:o :o Hope I post all the scripts again.

NOTE: You will have to modify the script for your own purposes.
NOTE: I used the custom field 4 in HESK to collect this mobile number.
NOTE: This will format number 082... to +278 automatically - international code for my country.

1. Add SMS function if the Admin replys to a ticket
admin\admin_reply_ticket.php (above line /* Add reply */)

//API Code: http://bulksms.2way.co.za:5567/eapi/sub ... 782xxxxxxx

$phone_number = trim($ticket['custom4']);
if (preg_match("/^0/", $phone_number)) {
$phone_number = preg_replace("/^0/", "+27", $phone_number);
}
if (strlen($phone_number) == 12) {
$text_message = "HESK responded to your ticket " . $ticket['trackid'] . ". Please check your emails for more detail.";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://bulksms.2way.co.za/eapi/submissi ... _sms/2/2.0");
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "username=xxxxxx&password=xxxxxxx&message=" . $text_message . "&msisdn=" . $phone_number);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 30);
$output = curl_exec($ch);

curl_close($ch);
}

2. Add the SMS function when the Admin submits a new ticket

admin\admin_submit_ticket.php (Above the line // Notify the customer about the ticket?)

//API Code: http://bulksms.2way.co.za:5567/eapi/sub ... 782xxxxxxx

$phone_number = trim($tmpvar['custom4']);
if (preg_match("/^0/", $phone_number)) {
$phone_number = preg_replace("/^0/", "+27", $phone_number);
}

if (strlen($phone_number) == 12) {
$text_message = "HESK received your ticket no. " . $ticket['trackid'] . ", check your email for updates.";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://bulksms.2way.co.za/eapi/submissi ... _sms/2/2.0");
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "username=xxxxx&password=xxxxx&message=" . $text_message . "&msisdn=" . $phone_number);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 30);
$output = curl_exec($ch);

curl_close($ch);
}

Re: HESK with SMS API function - script

Posted: Sat May 25, 2019 4:15 pm
by osmanemre
send me php file thankyou

Re: HESK with SMS API function - script

Posted: Sat May 25, 2019 4:29 pm
by osmanemre
failed code new version hesk mods system please update