URL:
URL:
URL:
Wait. Loading....
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | <script type= "text/javascript" > function makeShort() { var longUrl=document.getElementById( "longurl" ).value; var request = gapi.client.urlshortener.url.insert({ 'resource' : { 'longUrl' : longUrl } }); request.execute( function (response) { if (response.id != null ) { str = "<b>Long URL:</b>" +longUrl+ "<br />" ; str += "<b>Short URL:</b> <a href='" +response.id+ "'>" +response.id+ "</a><br />" ; document.getElementById( "output" ).innerHTML = str; } else { alert( "error: creating short url n" + response.error); } }); } function getShortInfo() { var shortUrl=document.getElementById( "shorturl" ).value; var request = gapi.client.urlshortener.url.get({ 'shortUrl' : shortUrl, 'projection' : 'FULL' }); request.execute( function (response) { if (response.longUrl!= null ) { str = "<b>Long URL:</b>" +response.longUrl+ "<br />" ; str += "<b>Create On:</b>" +response.created+ "<br />" ; str += "<b>Short URL Clicks:</b>" +response.analytics.allTime.shortUrlClicks+ "<br />" ; str += "<b>Long URL Clicks:</b>" +response.analytics.allTime.longUrlClicks+ "<br />" ; document.getElementById( "output" ).innerHTML = str; } else { alert( "error: " +response.error); } }); } function load() { //Get your own Browser API Key from https://code.google.com/apis/console/ gapi.client.setApiKey( 'AIzaSyD0Gwt6ptEKHCVSCUehjFhpbJG_v0IwQPY' ); gapi.client.load( 'urlshortener' , 'v1' , function (){document.getElementById( "output" ).innerHTML= "" ;}); } window.onload = load; </script> <input type= "button" value= "Create Short" onclick= "makeShort();" > <br> <br><br> <input type= "button" value= "Get Short URL Info" onclick= "getShortInfo();" ><br> <div id= "output" >Wait. Loading....</div> |
'C#' 카테고리의 다른 글
C# WebClient로 파일 다운 로드가 안될때 (0) | 2015.06.09 |
---|---|
비주얼 스튜디오 설치후 추가 확장 애드인 (0) | 2015.05.20 |
HighLight.JS 티스토리에서 사용 하기. (0) | 2014.07.06 |
C# 구글 ShortURL (0) | 2014.06.24 |
테스트 스크립트 (0) | 2014.06.23 |