. * * * * Additional conditions apply for your use of Google APIs. * * See http://code.google.com/terms.html for details. * * * * Contact: subhrajit@gmail.com, http://www.subhrajit.net/ * * * * * ****************************************************************************************** */ // goo.gl URL shortener. function Get_goo_gl_URL($LongURL) { $opts = array( 'http'=>array( 'method' => "POST", 'header' => "Content-Type: application/json", 'content' => "{\"longUrl\": \"".$LongURL."\"}" ) ); $context = stream_context_create($opts); $JSON_content = file_get_contents("https://www.googleapis.com/urlshortener/v1/url", false, $context); if ( preg_match("/\"id\"\\s*:\\s*\"(.*?)\"/i", $JSON_content, $matches) ) return($matches[1]); else return("ERROR in retrieving goo.gl URL."); } // PHP variable $ThisPageGooGlURL = Get_goo_gl_URL( $ScriptUrl.'?'.preg_replace("/\\?/","&",$_SERVER['QUERY_STRING'],1) ); //------------------------------------------------------ // Page variables // Just the URL $FmtPV['$ThisPageGooGlURL'] = '"'.$ThisPageGooGlURL.'"'; ?>