길이 이야기(Giri's Story)
[소셜(SNS)댓글] 네이버 미투데이(me2day) 연동 FAQ 본문
--------------------------------------------------------------------------------------------------------
요즘 소셜(SNS)댓글 시스템이 커뮤니티 사이트에서 관심을 받고 있습니다.
이전에 IT관련 회사들은 어떻게 하면 회원가입률을 높일까를 고민하다 이제는 어떻게 하면 커뮤니티를 활성화 시킬 수 있을까로 고민이 바뀌고 있죠. 말 그대로 좋은 정보를 제공하는 것도 중요하지만, 방문자의 호응을 쉽게 이끌어내기 위한 노력으로 SNS 댓글시스템이 각광을 받고 있지 않나 싶습니다.
각 SNS(트위터, 페이스북, 미투데이, 요즘 등) 서비스들의 로그인 API연동에 대한 FAQ를 정리해보도록 하겠습니다.
개발하실 분들은 참조해서 도움이 되셨으면 좋겠습니다.
--------------------------------------------------------------------------------------------------------
네이버 미투데이는 OAuth를 사용치 않고 자체 간편인증을 사용합니다.
일단 애플리케이션 키 요청 http://me2day.net/me2/app/get_appkey
- 키값발급 및 callback 설정
프로그램으로
------
$akey = "발급받은 키값";
http://me2day.net/api/get_auth_url.xml?akey=".$akey
------
의 형태로 값을 전달하면 로그인 인증창의 URL을 토큰키와 같이 돌려줍니다.
돌려받은 url로 리다이렉트 시킨 후 토큰과 결과, 사용자 정보를 callback 에서 검사후 사용하면 완료~
-----------------
index.php
-----------------
<?php
header("expires: Thu, 19 Nov 1981 08:52:00 GMT");
header("cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header("pragma: no-cache");
$akey = '발급받은 앱키";
$callback_url = '콜백URL/callback.php';
$response = http("http://me2day.net/api/get_auth_url.xml?akey=".$akey);
$get_url_tmp = explode("<url>", $response);
$get_url_tmp2 = $get_url_tmp[1];
$get_url_tmp3 = explode("</url>", $get_url_tmp2);
$url = $get_url_tmp3[0];
header('Location:'.$url);
function http($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close ($ch);
return $response;
}
?>
--------------------
callback.php
--------------------
<?php
header("expires: Thu, 19 Nov 1981 08:52:00 GMT");
header("cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header("pragma: no-cache");
include_once $g_Path_System . "/@inc/xml_parser_php5.php";
/**
* @file
* Take the user when they return from Twitter. Get access tokens.
* Verify credentials and redirect to based on response from Twitter.
*/
/* Start session and load lib */
$auth_token = ifilter($_REQUEST['token'], "STRING", 100);
$auth_result = ifilter($_REQUEST['result'], "STRING", 20);
$auth_user_id = ifilter($_REQUEST['user_id'], "STRING", 50);
$auth_user_key = ifilter($_REQUEST['user_key'], "STRING", 50);
$response = http("http://me2day.net/api/get_person/".$auth_user_id);
$parser = new XMLParser($response); // 객체생성 parser라는 객체를 생성함
$parser->Parse(); // Parse()메소를 호출하여 xml을 dom 방식으로 파싱함
$nickname = $parser->document->nickname[0]->tagData;
$profile_img_url = $parser->document->face[0]->tagData;
if(isset($auth_token) && isset($auth_result) && $auth_result == "true") {
/* The user has been verified and the access tokens can be saved for future use */
// 넘어온 인증정보를 통해 서버에 로그인 인증정보를 심기!
// 자체 프로그램 소스처리(DB를 저장하든, 세션으로 저장하든)
// ......
// ---------------------------------------------------
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta c"text/html; charset=utf-8" http-equiv="Content-Type" />
</head>
<body>
<script>
opener.location.reload();
self.close();
</script>
</body>
</html>
<?
} else {
/* Save HTTP status for error dialog on connnect page.*/
// header('Location: ./clearsessions.php');
Message("연동중 API오류가 발생하였습니다. 다시 시도해주세요.", "close");
}
function http($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close ($ch);
return $response;
}
?>
'IT기술,개발 > 웹프로그래밍' 카테고리의 다른 글
[소셜(SNS)댓글] 싸이월드-C로그 연동 FAQ (0) | 2011.11.17 |
---|---|
[소셜(SNS)댓글] twitter 연동 FAQ (0) | 2011.11.17 |
[소셜(SNS)댓글] 다음 요즘(yozm) 연동 FAQ (0) | 2011.11.17 |
[소셜(SNS)댓글] facebook 연동 FAQ #2 - file_get_contents() 함수문제 (0) | 2011.11.17 |
[소셜(SNS)댓글] facebook 연동 FAQ #1 - 페이스북 API 키 발급 (0) | 2011.11.17 |
[jQuery] 가시영역의 이미지만 로딩 - Lazy Load Plugin for jQuery (특정영역에만 적용가능) (0) | 2011.09.27 |
[Ajax] Microsoft.XMLHTTP(Ajax) - 서버 실시간 모니터링 (0) | 2011.09.27 |
[MYSQL] mysql data type (DB 데이터 타입) (0) | 2011.09.27 |
[Linux] 아파치 웹로그분석툴 webalizer 설치 (0) | 2011.03.31 |
crontab(cronjob) 스케쥴, php관리툴 응용제어 (0) | 2011.03.23 |