| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 클라우드
- 스팸글 차단
- WEB-INF 노출
- 암호화&복호화
- column명비교
- 자바스크립트
- POST 전송
- MARGIN
- fckeditor
- 청보리밭
- addbatch
- 자동 로봇 글등록
- 고창
- 스크롤 이동
- 퀵메뉴
- apache tomcat 연동 보안
- 네이버 지도API
- 2012 사진공모전
- PADDING
- XSS 차단
- html5
- Java
- 일괄처리
- 다음메일
- 비밀번호 유효성
- 치환
- 배경이 가려진 레이어 팝업
- 중복필드
- @tistory.com
- CSS
Archives
- Today
- Total
그곰의 생활
게시물 제목+URL SNS 링크 스크립트 본문
1. 잛은 URL(Short URL) 생성 -- PHP버전
/*
* SNS용 Short URL 생성
* mypikup.kr에서 제공하는 API를 이용
*/
function getShortURL($longUrl) {
$url = "http://mypickup.kr/?c=api&m=short&q=".urlencode($longUrl);
$data = file_get_contents($url);
$json = json_decode($data, true);
return urldecode($json['short_numalpha']);
}
$SNS_sURL = getShortUrl("http://".$SERVER_NAME."/".$PHP_SELF."?".$QUERY_STRING);
2. 자바스크립트로 링크 걸기
/*
* SNS용 Short URL 생성
* mypikup.kr에서 제공하는 API를 이용
*/
function getShortURL($longUrl) {
$url = "http://mypickup.kr/?c=api&m=short&q=".urlencode($longUrl);
$data = file_get_contents($url);
$json = json_decode($data, true);
return urldecode($json['short_numalpha']);
}
$SNS_sURL = getShortUrl("http://".$SERVER_NAME."/".$PHP_SELF."?".$QUERY_STRING);
/*
* SNS 링크 연결
* 사용방법 goSns(msg,url,mode)
* msg : 게시물 제목
* url : 현재 페이지 Full URL
* mode : twitter, facebook, me2day, yozm 중 서비스하는 SNS 영문명
*/
var SNS_SHORT_URL = '';
function goSns(msg,url,mode){
if(SNS_SHORT_URL == ''){
$.post("/ajax/get_short_url", { url:url },
function(data){
if(data.result == 'true')
{
SNS_SHORT_URL = data.url;
social_type(msg,SNS_SHORT_URL,mode);
}
else
{
alert(data.message);
}
}, "json");
}else{
social_type(msg,SNS_SHORT_URL,mode);
}
}
// 종류별 분기
function social_type(msg,url,mode){
// 트위터
if(mode == 'twitter'){
goTwitter(msg,url);
}
// 페이스북
else if(mode == 'facebook'){
goFaceBook(msg,url);
}
// 미투데이
else if(mode == 'me2day'){
goMe2Day(msg,url, '사이트 이름');
}
// 요즘
else if(mode == 'yozm'){
goYozmDaum(url,msg,msg);
}
}
// 트위터
function goTwitter(msg,url) {
var href = "http://twitter.com/home?status=" + encodeURIComponent(msg) + " " + encodeURIComponent(url);
var a = window.open(href, 'twitter', '');
if ( a ) {
a.focus();
}
}
// 미투데이
function goMe2Day(msg,url,tag) {
url = '"'+url+'":'+url
var href = "http://me2day.net/posts/new?new_post[body]=" + encodeURIComponent(msg) + " " + encodeURIComponent(url) + "&new_post[tags]=" + encodeURIComponent(tag);
var a = window.open(href, 'me2Day', '');
if ( a ) {
a.focus();
}
}
// 페이스북
function goFaceBook(msg,url) {
var href = "http://www.facebook.com/sharer.php?u=" + url + "&t=" + encodeURIComponent(msg);
var a = window.open(href, 'facebook', '');
if ( a ) {
a.focus();
}
}
// 요즘
function goYozmDaum(link,prefix,parameter) {
var href = "http://yozm.daum.net/api/popup/prePost?sourceid=54&link=" + encodeURIComponent(link) + "&prefix=" + encodeURIComponent(prefix) + "¶meter=" + encodeURIComponent(parameter);
var a = window.open(href, 'yozmSend', 'width=466, height=356');
if ( a ) {
a.focus();
}
}
'Client-side > SCRIPT' 카테고리의 다른 글
| jQuery를 이용한 배경이 가려진 레이어 팝업 뛰우기 (0) | 2011.11.17 |
|---|---|
| 자바스크립트 Form 생성하여 Post 전송 (3) | 2011.11.15 |
| [스크랩] 비밀번호 유효성 검사 (0) | 2011.10.06 |
| [스크랩]영문, 숫자, 한글, 이메일 확인 스크립트 (0) | 2011.07.25 |
| [스크립트] 왼쪽 메뉴 지정 스크립트 (0) | 2011.07.22 |
Comments