public function shortenUrl($url, $provider)
    {
        if (!empty($url) && !empty($provider)) {
            if ($provider == 'tinyurl') {
                $url_data = sprintf($this->_tinyUrlShortApiUrl, $url);
            } elseif ($provider == 'google') {
                $url_data = sprintf('%s/url', $this->_googleShortApiUrl);
            }

            switch ($provider) {
                case 'tinyurl':
                    $ch = curl_init($url_data);  
                    $timeout = 5;  
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
                    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);  
                    $result = curl_exec($ch);  
                    curl_close($ch);

                    return $result; 
                    break;

                case 'google':
                    $ch = curl_init($url_data);
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                    $requestData = array(
                        'longUrl' => $url
                    );

                    curl_setopt($ch, CURLOPT_POST, true);
                    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestData));
                    $result = json_decode(curl_exec($ch), true);
                    curl_close($ch);

                    return $result['id'];
                    break;
                
                default:
                    return false;
                    break;
            }
        }
        return false;
    }