1function sendsns(sns, url, txt)
2{
3    var o;
4    var _url = encodeURIComponent(url);
5    var _txt = encodeURIComponent(txt);
6    var _br  = encodeURIComponent('\r\n');
7
8    switch(sns)
9    {
10        case 'facebook':
11            o = {
12                method:'popup',
13                url:'http://www.facebook.com/sharer/sharer.php?u=' + _url
14            };
15            break;
16
17        case 'twitter':
18            o = {
19                method:'popup',
20                url:'http://twitter.com/intent/tweet?text=' + _txt + '&url=' + _url
21            };
22            break;
23
24        case 'me2day':
25            o = {
26                method:'popup',
27                url:'http://me2day.net/posts/new?new_post[body]=' + _txt + _br + _url + '&new_post[tags]=epiloum'
28            };
29            break;
30
31        case 'kakaotalk':
32            // https://developers.kakao.com/docs/js#카카오톡-링크-예제:-동적으로-바뀌는-내용의-카카오톡-링크-보내기
33
34            if( navigator.userAgent.match(/Android/i)
35             || navigator.userAgent.match(/webOS/i)
36             || navigator.userAgent.match(/iPhone/i)
37             || navigator.userAgent.match(/iPad/i)
38             || navigator.userAgent.match(/iPod/i)
39             || navigator.userAgent.match(/BlackBerry/i)
40             || navigator.userAgent.match(/Windows Phone/i)
41             ){
42                 Kakao.init('86e29ce3fe186b0c17e467c991beea62');
43
44                        Kakao.Link.sendTalkLink({
45                        label: txt
46                  });
47              }
48             else {
49                 alert('이 기능은 모바일에서만 사용할 수 있습니다.');
50              }
51
52
53            break;
54
55        case 'kakaostory':
56            o = {
57                method:'web2app',
58                param:'posting?post=' + _txt + _br + _url + '&apiver=1.0&appver=2.0&appid=dev.epiloum.net&appname=' + encodeURIComponent('Epiloum 개발노트'),
59                a_store:'itms-apps://itunes.apple.com/app/id486244601?mt=8',
60                g_store:'market://details?id=com.kakao.story',
61                a_proto:'storylink://',
62                g_proto:'scheme=kakaolink;package=com.kakao.story'
63            };
64            break;
65
66        case 'band':
67            o = {
68                method:'web2app',
69                param:'create/post?text=' + _txt + _br + _url,
70                a_store:'itms-apps://itunes.apple.com/app/id542613198?mt=8',
71                g_store:'market://details?id=com.nhn.android.band',
72                a_proto:'bandapp://',
73                g_proto:'scheme=bandapp;package=com.nhn.android.band'
74            };
75            break;
76
77        default:
78            alert('지원하지 않는 SNS입니다.');
79            return false;
80    }
81
82    switch(o.method)
83    {
84        case 'popup':
85            window.open(o.url, "오픈위키 펌질하기", "width=410, height=540, resizable=no");
86            break;
87
88        case 'web2app':
89            if(navigator.userAgent.match(/android/i))
90            {
91                // Android
92                setTimeout(function(){ location.href = 'intent://' + o.param + '#Intent;' + o.g_proto + ';end'}, 100);
93            }
94            else if(navigator.userAgent.match(/(iphone)|(ipod)|(ipad)/i))
95            {
96                // Apple
97                setTimeout(function(){ location.href = o.a_store; }, 200);
98                setTimeout(function(){ location.href = o.a_proto + o.param }, 100);
99            }
100            else
101            {
102                alert('이 기능은 모바일에서만 사용할 수 있습니다.');
103            }
104            break;
105    }
106}