function bitly($xxurl) { function get_bitly_short_url($url, $login, $appkey, $format = 'txt') { $connectURL = 'http://api.bit.ly/v3/shorten?login='******'&apiKey=' . $appkey . '&uri=' . urlencode($url) . '&format=' . $format; return curl_get_result($connectURL); } function curl_get_result($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); curl_close($ch); return $data; } return $short_url = get_bitly_short_url($xxurl, 'cl17726', 'R_8b11d4a89732abac4fb46ef9b40f54ec'); }
$zip->close(); //check to make sure the file exists return file_exists($destination); } else { return false; } } //Get the current page's URL and convert to a short URL $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; /* get the short url */ $short_url = get_bitly_short_url($pageURL, 'tmurzens', 'R_e8194fd945830f544ddf77581860d5ae'); /* get the long url from the short one */ //$long_url = get_bitly_long_url($short_url,'tmurzens','R_e8194fd945830f544ddf77581860d5ae'); ?> <!doctype html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Subscribe | MasterCard WorldWide Insights</title> <meta name="description" content="Sign up to get Mastercard insights in your inbox."> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="/css/central.css" type="text/css" />
function get_bitly_short_url($address, $login, $appkey, $format = 'txt') { $connectURL = 'http://api.bit.ly/v3/shorten?login='******'&apiKey=' . $appkey . '&uri=' . urlencode($address) . '&format=' . $format; return curl_get_result($connectURL); } /* returns expanded url */ function get_bitly_long_url($address, $login, $appkey, $format = 'txt') { $connectURL = 'http://api.bit.ly/v3/expand?login='******'&apiKey=' . $appkey . '&shortUrl=' . urlencode($address) . '&format=' . $format; return curl_get_result($connectURL); } /* returns a result form url */ function curl_get_result($address) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $address); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); curl_close($ch); return $data; } $bitly_user = '******'; $bitly_key = 'R_cc291fcd3bd5474eaefaeed69cc0f090'; /////////// if ($_GET['bitly']) { $bitly_short_url = get_bitly_short_url($_GET['bitly'], $bitly_user, $bitly_key); $bitly = $bitly_short_url; echo $bitly; }
{ $connectURL = 'http://api.bit.ly/v3/shorten?login='******'&apiKey=' . $appkey . '&uri=' . urlencode($url) . '&format=' . $format; return curl_get_result($connectURL); } /* returns expanded url */ /* function get_bitly_long_url($url,$login,$appkey,$format='txt') { $connectURL = 'http://api.bit.ly/v3/expand?login='******'&apiKey='.$appkey.'&shortUrl='.urlencode($url).'&format='.$format; return curl_get_result($connectURL); } */ /* returns a result form url */ function curl_get_result($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); curl_close($ch); return $data; } /* get the short url */ $short_url = get_bitly_short_url('http://www.naver.com', 'kyhfan', 'R_11ea80ffc2bf4bbe8c848b761e71df8a'); print_r($short_url); /* get the long url from the short one */ //$long_url = get_bitly_long_url($short_url,'kyhfan','R_11ea80ffc2bf4bbe8c848b761e71df8a'); ?>
$oauth_access_token_secret = ''; } /* returns the shortened url */ function get_bitly_short_url($url, $login, $appkey, $format = 'txt') { $connectURL = 'http://api.bit.ly/v3/shorten?login='******'&apiKey=' . $appkey . '&uri=' . urlencode($url) . '&format=' . $format; return curl_get_result($connectURL); } /* returns a result form url */ function curl_get_result($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $data = curl_exec($ch); curl_close($ch); return $data; } //print_r($share_link); /* get the short url */ $short_url = get_bitly_short_url($share_link, 'kannansp', 'R_2c7f253e911e440093c97ca3788ebff2'); $tweet_message = "The new deal has been posted with best offer. Hurry up!!! " . $short_url; /* Create TwitterOAuth with app key/secret and user access key/secret */ $to = new TwitterOAuth($consumer_key, $consumer_secret, $oauth_access_token, $oauth_access_token_secret); /* Run request on twitter API as user. */ //$content = $to->OAuthRequest('https://twitter.com/account/verify_credentials.xml', array(), 'GET'); $content = $to->OAuthRequest('https://twitter.com/statuses/update.xml', array('status' => $tweet_message), 'POST'); ?>