1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Adding tiny url service to "tweet this" plugin?

Discussion in 'Blogging' started by Brotato, Jul 21, 2009.

  1. Brotato

    Brotato Regular Member

    Joined:
    Mar 10, 2008
    Messages:
    235
    Likes Received:
    59
    I'd like to add another url shortening service to the tweet this plugin but I'm not sure how to do it. I'm pretty sure it's in this section of coding

    Code:
    function get_tweet_this_short_url() {
    	global $id;
    	$purl = get_permalink();
    	$cached_url = get_post_meta($id, 'tweet_this_url', true);
    	if($cached_url && $cached_url != 'getnew')
    		return $cached_url;
    	else {
    		$u = tt_option('tt_url_service');
    		if(ini_get('allow_url_fopen') == 1 ||
    			ini_get('allow_url_fopen') == 'on' ||
    			ini_get('allow_url_fopen') == 'On' ||
    			function_exists('curl_init'))
    				$u = $u;
    			else $u = 'local';
    		switch($u) {
    		case 'adjix': {
    			if(tt_option('tt_adjix_api_key') == '')
    				$adid = '';
    			else $adid = '&partnerID=' .
    				tt_option('tt_adjix_api_key');
    			if(tt_option('tt_ad_vu') != 'true')
    				$s = '';
    			else $s = '&ultraShort=y';
    			$url = tt_read_file('http://api.adjix.com/shrinkLink' .
    				'?url=' . $purl . $adid . $s);
    			}
    			break;
    		case 'bit.ly':
    			$url = tt_read_file('http://bit.ly/api?url=' . $purl);
    			break;
    		case 'h3o.de':
    			$url = tt_read_file('http://h3o.de/api/index.php?' .
    			'url=' . $purl);
    			break;
    		case 'hex.io':
    			$url = str_replace('www.', '', tt_read_file('http://' .
    			'www.hex.io/api-create.php?url=' . $purl));
    			break;
    		case 'idek.net':
    			$url = tt_read_file('http://idek.net/c.php?idek-api=' .
    			'true&idek-ref=Tweet+This&idek-url=' . $purl);
    			break;
    		case '************':
    			$url = tt_read_file('http://************/api.php?longurl=' .
    			$purl);
    			break;
    		case 'lin.cr':
    			$url = tt_read_file('http://lin.cr/?mode=api&full=1' .
    			'&l=' . $purl);
    			break;
    		case 'metamark':
    			$url = tt_read_file('http://metamark.net/api/rest/' .
    			'simple?long_url=' . $purl);
    			break;
    		case 'ri.ms':
    			$url = tt_read_file('http://ri.ms/api-create.php?' .
    			'url=' . $purl);
    			break;
    		case 'snurl':
    			$url = tt_read_file('http://snurl.com/site/snip?r=' .
    			'simple&link=' . $purl);
    			break;
    		case 'tinyurl':
    			$url = tt_read_file('http://************************/' .
    			'api-create.php?url=' . $purl);
    			break;
    		case 'urlb.at':
    			$url = tt_read_file('http://urlb.at/api/rest/?url=' .
    			urlencode($purl));
    			break;
    		case 'tweetburner': {
    			if(function_exists('curl_init')) {
    			$ch = curl_init('http://tweetburner.com/links');
    			curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    			curl_setopt($ch,CURLOPT_POST,1);
    			curl_setopt($ch,CURLOPT_POSTFIELDS,'link[url]=$purl');
    			curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5);
    			$url = curl_exec($ch);
    			curl_close($ch);
    			}
    			else $u = 'local';
    			}
    			break;
    		case 'local': {
    			global $id;
    			$url = get_bloginfo('url') . '/?p=' . $id;
    			}
    			break;
    		default:
    			$url = tt_read_file('http://th8.us/api.php?url=' .
    			$purl . '&client=Tweet+This+v1.4.1&format=simple');
    		}
    		if(tt_option('tt_url_www') == 'true' && $u != 'tweetburner') {
    			$url = str_replace('http://www.', 'www.', $url);
    			$url = str_replace('http://', 'www.', $url);
    			}
    		if($u != 'local' && (strlen($url) > 30 || $url == 'Error' ||
    			$url == 'www.' || $url == 'http://'))
    			$url = get_bloginfo('url') . '/?p=' . $id;
    		if(tt_option('tt_30') == 'true' && strlen($purl) < 30) {
    			$url = $purl; if(tt_option('tt_url_www') == 'true') {
    				$url = str_replace('http://www.', 'www.',
    					$url);
    				$url = str_replace('http://', 'www.', $url);
    				}
    			}
    		if($cached_url == 'getnew')
    			update_post_meta($id, 'tweet_this_url', $url,
    			'getnew');
    		else add_post_meta($id, 'tweet_this_url', $url, true);
    		}
    	return $url;
    }
    
    
    /**
     * Echoes the above function for convenience.
     */
    function tweet_this_short_url() {
    	echo	get_tweet_this_short_url();
    }
    
    
    Service I'd like to add is http://tinyftw.com
     
  2. Brotato

    Brotato Regular Member

    Joined:
    Mar 10, 2008
    Messages:
    235
    Likes Received:
    59
    no one knows?