Example #1
0
function do_post_request($data, $pushTest = false)
{
    $push_url = 'http://push.tapatalk.com/push.php';
    $response = getPushContentFromRemoteServer($push_url, $pushTest ? 10 : 0, $error, 'POST', $data);
    return $response;
}
Example #2
0
function tt_do_post_request($data)
{
    global $boardurl, $modSettings;
    $push_url = 'http://push.tapatalk.com/push.php';
    if (!function_exists('updateSettings')) {
        require_once $sourcedir . '/Subs.php';
    }
    //Initial this key in modSettings
    if (!isset($modSettings['push_slug'])) {
        updateSettings(array('push_slug' => 0));
    }
    //Get push_slug from db
    $push_slug = isset($modSettings['push_slug']) ? $modSettings['push_slug'] : 0;
    $slug = base64_decode($push_slug);
    $slug = push_slug($slug, 'CHECK');
    $check_res = unserialize($slug);
    //If it is valide(result = true) and it is not sticked, we try to send push
    if ($check_res['result'] && !$check_res['stick']) {
        //Slug is initialed or just be cleared
        if ($check_res['save']) {
            updateSettings(array('push_slug' => base64_encode($slug)));
        }
        //Send push
        $push_resp = getPushContentFromRemoteServer($push_url, 0, $error, 'POST', $data);
        if (trim($push_resp) === 'Invalid push notification key') {
            $push_resp = 1;
        }
        if (!is_numeric($push_resp)) {
            //Sending push failed, try to update push_slug to db
            $slug = push_slug($slug, 'UPDATE');
            $update_res = unserialize($slug);
            if ($update_res['result'] && $update_res['save']) {
                updateSettings(array('push_slug' => base64_encode($slug)));
            }
        }
    }
}