function uplink_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0) { // global $plugin_config; // global all variables needed, eg: varibles from config.php // ... // ... // return true or false // return $ok; global $plugin_config; _log("enter smsc:" . $smsc . " smslog_id:" . $smslog_id . " uid:" . $uid . " to:" . $sms_to, 3, "uplink_hook_sendsms"); // override plugin gateway configuration by smsc configuration $plugin_config = gateway_apply_smsc_config($smsc, $plugin_config); $sms_sender = stripslashes($sms_sender); if ($plugin_config['uplink']['module_sender']) { $sms_sender = $plugin_config['uplink']['module_sender']; } $sms_footer = $sms_footer ? $sms_footer : stripslashes($sms_footer); $sms_msg = stripslashes($sms_msg) . $sms_footer; $ok = false; if ($sms_to && $sms_msg) { $unicode = trim($unicode) ? 1 : 0; $nofooter = $plugin_config['uplink']['try_disable_footer'] ? 1 : 0; $ws = new Playsms\Webservices(); $ws->url = $plugin_config['uplink']['master'] . '/index.php?app=ws'; $ws->username = $plugin_config['uplink']['username']; $ws->token = $plugin_config['uplink']['token']; $ws->to = $sms_to; $ws->from = $sms_sender; $ws->msg = $sms_msg; $ws->unicode = $unicode; $ws->nofooter = $nofooter; $ws->sendSms(); // _log('url:'.$ws->getWebservicesUrl(), 3, 'uplink sendsms'); if ($ws->getStatus()) { $response = $ws->getData(); $db_query = "\n\t\t\t\tINSERT INTO " . _DB_PREF_ . "_gatewayUplink (up_local_smslog_id,up_remote_smslog_id,up_status,up_remote_queue_code,up_dst)\n\t\t\t\tVALUES ('{$smslog_id}','" . $response->smslog_id . "','0','" . $response->queue . "','{$sms_to}')"; if ($up_id = @dba_insert_id($db_query)) { $ok = true; } _log('sendsms success. smslog_id:' . $smslog_id . ' remote_smslog_id:' . $response->smslog_id . ' remote_queue:' . $response->queue, 3, 'uplink sendsms'); } else { _log('sendsms failed. error:' . $ws->getError() . ' error_string:' . $ws->getErrorString(), 3, 'uplink sendsms'); } } if ($ok && ($response->smslog_id || $response->queue)) { $p_status = 0; } else { $p_status = 2; } dlr($smslog_id, $uid, $p_status); return $ok; }
<?php include '../src/Playsms/Webservices.php'; error_reporting(E_ALL ^ E_NOTICE); $ws = new Playsms\Webservices(); $ws->url = 'http://playsms.org/trial/index.php?app=ws'; $ws->username = '******'; $ws->password = '******'; echo "\ngetToken\n"; $ws->getToken(); print_r($ws->getData()); echo "\n"; if ($ws->getStatus()) { $ws->token = $ws->getData()->token; echo "Credit\n\n"; $ws->getCredit(); if ($ws->getStatus()) { $credit = $ws->getData()->credit; echo "Remaining credit for user " . $ws->username . ": " . $credit . "\n"; } else { echo "Unable to check user credit\n"; } } else { echo "Error code: " . $ws->getError() . "\n"; echo "Error string: " . $ws->getErrorString() . "\n"; } echo "\n";
<?php include '../src/Playsms/Webservices.php'; error_reporting(E_ALL ^ E_NOTICE); $ws = new Playsms\Webservices(); // if you want to test with other username // go to http://playsms.id and register for username/password // visit http://playsms.org/demo for more information $ws->url = 'http://playsms.id/index.php?app=ws'; $ws->username = '******'; $ws->token = 'your_token'; $ws->to = 'destination_number'; $ws->msg = 'Hello u there, good morning'; $ws->nofooter = 1; $ws->sendSms(); //print_r($ws) . PHP_EOL; if ($ws->getStatus()) { echo "Status: TRUE" . PHP_EOL; $response = $ws->getData(); print_r($response) . PHP_EOL; } else { echo "Status: FALSE" . PHP_EOL; echo "Error code: " . $ws->getError() . PHP_EOL; echo "Error string: " . $ws->getErrorString() . PHP_EOL; }
/** * hook_sendsms called by sendsms_process() * * @param string $smsc * SMSC name * @param unknown $sms_sender * Sender ID * @param string $sms_footer * Message footer * @param string $sms_to * Destination number * @param string $sms_msg * Message * @param integer $uid * User ID * @param integer $gpid * Group ID * @param integer $smslog_id * SMS Log ID * @param integer $sms_type * Type of SMS * @param integer $unicode * Unicode flag * @return boolean */ function uplink_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0) { // global $plugin_config; // global all variables needed, eg: varibles from config.php // ... // ... // return true or false // return $ok; global $plugin_config; _log("enter smsc:" . $smsc . " smslog_id:" . $smslog_id . " uid:" . $uid . " to:" . $sms_to, 3, "uplink_hook_sendsms"); // override plugin gateway configuration by smsc configuration $plugin_config = gateway_apply_smsc_config($smsc, $plugin_config); $sms_sender = stripslashes($sms_sender); if ($plugin_config['uplink']['module_sender']) { $sms_sender = $plugin_config['uplink']['module_sender']; } $sms_footer = $sms_footer ? $sms_footer : stripslashes($sms_footer); $sms_msg = stripslashes($sms_msg) . $sms_footer; $ok = FALSE; if ($sms_to && $sms_msg) { $unicode = trim($unicode) ? 1 : 0; $nofooter = $plugin_config['uplink']['try_disable_footer'] ? 1 : 0; $ws = new Playsms\Webservices(); $ws->url = $plugin_config['uplink']['master'] . '/index.php?app=ws'; $ws->username = $plugin_config['uplink']['username']; $ws->token = $plugin_config['uplink']['token']; $ws->to = $sms_to; $ws->from = $sms_sender; $ws->msg = $sms_msg; $ws->unicode = $unicode; $ws->nofooter = $nofooter; $ws->sendSms(); _log('sendsms url:[' . $ws->getWebservicesUrl() . '] smsc:[' . $smsc . ']', 3, 'uplink_hook_sendsms'); // in playsms-webservices 1.0.5 and above the data returns as an array, unless a failed response $response = $ws->getData(); if (is_array($response->data)) { $data = $response->data[0]; } else { $data = $response; } //_log('data:[' . print_r($data, 1) . ']', 3, 'uplink_hook_sendsms'); if ($data->status == 'OK') { if ($data->smslog_id || $data->queue) { $db_query = "\n\t\t\t\tINSERT INTO " . _DB_PREF_ . "_gatewayUplink (up_local_smslog_id,up_remote_smslog_id,up_status,up_remote_queue_code,up_dst)\n\t\t\t\tVALUES ('{$smslog_id}','" . $data->smslog_id . "','0','" . $data->queue . "','{$sms_to}')"; if ($up_id = @dba_insert_id($db_query)) { $ok = TRUE; _log('sendsms success. smslog_id:' . $smslog_id . ' remote_smslog_id:' . $data->smslog_id . ' remote_queue:' . $data->queue, 3, 'uplink_hook_sendsms'); } else { $ok = TRUE; $p_status = 1; // sent dlr($smslog_id, $uid, $p_status); _log('sendsms success but unable to save data', 3, 'uplink_hook_sendsms'); return $ok; } } else { _log('sendsms failed no smslog_id or queue', 3, 'uplink_hook_sendsms'); } } else { _log('sendsms failed. error:' . $ws->getError() . ' error_string:' . $ws->getErrorString(), 3, 'uplink_hook_sendsms'); } } if ($ok && ($data->smslog_id || $data->queue)) { $p_status = 0; // pending } else { $p_status = 2; // failed } dlr($smslog_id, $uid, $p_status); return $ok; }