Beispiel #1
0
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";
Beispiel #3
0
<?php

error_reporting(E_ALL ^ E_NOTICE);
require 'vendor/autoload.php';
$ws = new Playsms\Webservices();
// if you want to test with other username
// go to http://playsms.org/trial and register for username/password
// its a demo website, sms will not be sent to mobiles
$ws->url = 'http://playsms.org/trial/index.php?app=ws';
$ws->username = '******';
$ws->password = '******';
// get token from username and password
$ws->getToken();
if (!$ws->getStatus()) {
    echo "Error code: " . $ws->getError() . "\n";
    echo "Error string: " . $ws->getErrorString() . "\n";
    exit;
}
echo "Token: " . $ws->getData()->token . "\n";
// get user's credit
$ws->token = $ws->getData()->token;
$ws->getCredit();
$credit = $ws->getStatus ? $ws->getData()->credit : 0;
echo "User credit: " . $credit . "\n";
Beispiel #4
0
<?php

error_reporting(E_ALL ^ E_NOTICE);
require 'vendor/autoload.php';
$ws = new Playsms\Webservices();
include 'config.php';
// if you want to test with other username
// go to http://playsms.org/trial and register for username/password
// its a demo website, sms will not be sent to mobiles
$ws->url = $config['webservices_url'];
$ws->username = $config['webservices_username'];
$ws->token = $config['webservices_token'];
// get user's credit just to test authentication
$ws->getCredit();
$credit = $ws->getStatus() ? $ws->getData()->credit : 'ERR';
if ($credit == 'ERR') {
    header('Location: error_auth.html');
    exit;
}
if ($credit <= 0) {
    header('Location: error_fund.html');
    exit;
}