function ShortenBitLy($url, $login = WSO_SURL::BITLY_LOGIN, $apikey = WSO_SURL::BITLY_API_KEY) { $bitly = WSO_SURL::BITLY_SHORTEN_URL . '?longUrl=' . urlencode($url) . '&login='******'&apiKey=' . $apikey . '&format=json'; $response = file_get_contents($bitly); $json = json_decode($response, true); if ($json['status_txt'] != "OK") { return WSO_SURL::Shorten($url); } return $json['data']['url']; }
private function getShortenLink($postid) { $wsoOpts = get_option(WSO_OPTIONS); $lnk = get_permalink($postid) . "?utm_source=Twitter&utm_medium=social&utm_campaign=WordSocial"; switch ($wsoOpts[$this->m_options['short_method']]) { case 'bitly': return WSO_SURL::ShortenBitLy($lnk); case 'obitly': return WSO_SURL::ShortenBitLy($lnk, $wsoOpts[$this->m_options['short_method_id']][0], $wsoOpts[$this->m_options['short_method_id']][1]); case 'yourls': return WSO_SURL::Shorten($lnk, $wsoOpts[$this->m_options['short_method_id']][0], $wsoOpts[$this->m_options['short_method_id']][1]); } return WSO_SURL::Shorten(get_permalink($postid)); }