sns 글등록 진행중

This commit is contained in:
gnuboard
2013-05-27 18:24:35 +09:00
parent 45f46b5b92
commit f87e0e134f
14 changed files with 172 additions and 9 deletions

View File

@ -753,6 +753,18 @@ $pg_anchor = '<ul class="anchor">
<input type="text" name="cf_twitter_secret" value="<?php echo $config['cf_twitter_secret'] ?>" id="cf_twitter_secret" class="frm_input" size="35">
</td>
</tr>
<tr>
<th scope="row"><label for="cf_me2day_key">미투데이 Key</label></th>
<td colspan="3">
<input type="text" name="cf_me2day_key" value="<?php echo $config['cf_me2day_key'] ?>" id="cf_me2day_key" class="frm_input"> <a href="http://me2day.net/me2/app/get_appkey" target="_blank" class="btn_frmline">앱 등록하기</a>
</td>
</tr>
<tr>
<th scope="row"><label for="cf_googl_shorturl_apikey">구글 짧은주소 API Key</label></th>
<td>
<input type="text" name="cf_googl_shorturl_apikey" value="<?php echo $config['cf_googl_shorturl_apikey'] ?>" id="cf_googl_shorturl_apikey" class="frm_input"> <a href="http://code.google.com/apis/console/" target="_blank" class="btn_frmline">API Key 등록하기</a>
</td>
</tr>
</tbody>
</table>
</section>

View File

@ -101,14 +101,15 @@ $sql = " update {$g4['config_table']}
cf_mobile_connect_skin = '{$_POST['cf_mobile_connect_skin']}',
cf_mobile_member_skin = '{$_POST['cf_mobile_member_skin']}',
cf_gcaptcha_mp3 = '{$_POST['cf_gcaptcha_mp3']}',
cf_googl_shorturl_apikey = '{$_POST['cf_googl_shorturl_apikey']}',
cf_kcpcert_site_cd = '{$_POST['cf_kcpcert_site_cd']}',
cf_kcpcert_use = '{$_POST['cf_kcpcert_use']}',
cf_facebook_use = '{$_POST['cf_facebook_use']}',
cf_sns_use = '{$_POST['cf_sns_use']}',
cf_facebook_appid = '{$_POST['cf_facebook_appid']}',
cf_facebook_secret = '{$_POST['cf_facebook_secret']}',
cf_twitter_use = '{$_POST['cf_twitter_use']}',
cf_twitter_key = '{$_POST['cf_twitter_key']}',
cf_twitter_secret = '{$_POST['cf_twitter_secret']}',
cf_me2day_key = '{$_POST['cf_me2day_key']}',
cf_1_subj = '{$_POST['cf_1_subj']}',
cf_2_subj = '{$_POST['cf_2_subj']}',
cf_3_subj = '{$_POST['cf_3_subj']}',

28
bbs/sns_send.php Normal file
View File

@ -0,0 +1,28 @@
<?php
include_once("./_common.php");
$title = str_replace('\"', '"',$_REQUEST['title']);
$short_url = googl_short_url($_REQUEST['longurl']);
$title_url = $title.' : '.$short_url;
switch($_REQUEST['sns']) {
case 'facebook' :
header("Location:http://www.facebook.com/sharer/sharer.php?s=100&p[url]=".$short_url."&p[title]=".$title);
break;
case 'twitter' :
header("Location:http://twitter.com/home?status=".$title_url);
break;
case 'me2day' :
header("Location:http://me2day.net/posts/new?new_post[body]=".$title_url);
break;
case 'yozm' :
header("Location:http://yozm.daum.net/api/popup/prePost?sourceid=41&prefix=".$title_url);
break;
case 'gplus' :
header("Location:https://plus.google.com/share?url=".$short_url);
break;
default :
echo 'Error';
}
?>

View File

@ -1,9 +1,15 @@
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
if ($config['cf_sns_use']) return;
if (!$config['cf_sns_use']) return;
set_cookie('ck_facebook_checked', false);
set_cookie('ck_twitter_checked' , false);
set_cookie('ck_me2day_checked' , false);
//============================================================================
// 페이스북
//----------------------------------------------------------------------------
if ($_POST['facebook_checked']) {
include_once(G4_SNS_PATH."/facebook/src/facebook.php");
@ -26,13 +32,19 @@ if ($_POST['facebook_checked']) {
// 등록
$facebook->api('/me/feed/', 'post', $attachment);
//$errors = error_get_last(); print_r2($errros); exit;
set_cookie('ck_facebook_checked', true, 86400*31);
} catch(FacebookApiException $e) {
;;;
}
}
}
//============================================================================
//============================================================================
// 트위터
//----------------------------------------------------------------------------
if ($_POST['twitter_checked']) {
include_once(G4_SNS_PATH."/twitter/twitteroauth/twitteroauth.php");
include_once(G4_SNS_PATH."/twitter/config.php");
@ -45,6 +57,25 @@ if ($_POST['twitter_checked']) {
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
// 등록
$connection->post('statuses/update', array('status' => $post));
set_cookie('ck_twitter_checked', true, 86400*31);
}
}
//============================================================================
//============================================================================
// 미투데이
//----------------------------------------------------------------------------
if ($_POST['me2day_checked']) {
if (!empty($_SESSION['me2day']['user_id']) && !empty($_SESSION['me2day']['user_key'])) {
$user_id = $_SESSION['me2day']['user_id'];
$user_key = $_SESSION['me2day']['user_key'];
$auth_key = "12345678" . md5("12345678" . $user_key);
$result = file_get_contents("http://me2day.net/api/create_post/{$user_id}.json?uid={$user_id}&ukey={$auth_key}&akey=".$config['cf_me2day_key']."&post[body]=".urlencode($wr_content));
set_cookie('ck_me2day_checked', true, 86400*31);
}
}
//============================================================================
?>

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
plugin/sns/icon/gplus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
plugin/sns/icon/me2day.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,3 @@
<?php
include_once("../../../common.php");
?>

View File

@ -0,0 +1,52 @@
<?php
include_once("./_common.php");
$user_id = $_GET['user_id'];
$user_key = $_GET['user_key'];
$auth_key = "12345678" . md5("12345678" . $user_key);
$_SESSION['me2day']['user_id'] = $user_id;
$_SESSION['me2day']['user_key'] = $user_key;
$g4['title'] = '미투데이 콜백';
include_once(G4_PATH.'/head.sub.php');
$result = json_decode(file_get_contents("http://me2day.net/api/noop.json?uid={$user_id}&ukey={$auth_key}&akey=".$config['cf_me2day_key']));
if ($result->code == 0) {
$user = json_decode(file_get_contents("http://me2day.net/api/get_person/{$user_id}.json"));
$sns_name = $user->nickname;
$g4_sns_url = G4_SNS_URL;
set_cookie('ck_sns_name', $sns_name);
echo <<<EOT
<script>
$(function() {
document.write("<strong>미투데이에 승인이 되었습니다.</strong>");
var opener = window.opener;
opener.$("#wr_name").val("{$sns_name}");
opener.$("#me2day_icon").attr("src", "{$g4_sns_url}/icon/me2day_on.png");
opener.$("#me2day_checked").attr("disabled", false);
opener.$("#me2day_checked").attr("checked", true);
window.close();
});
</script>
EOT;
} else {
echo <<<EOT
<script>
$(function() {
alert("미투데이에 승인이 되지 않았습니다.");
window.close();
});
</script>
EOT;
}
include_once(G4_PATH.'/tail.sub.php');
?>

View File

@ -169,6 +169,18 @@ include_once(G4_LIB_PATH.'/thumbnail.lib.php');
?>
</article>
<?php
$sns_send = G4_BBS_URL.'/sns_send.php?longurl='.urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$sns_send .= '&amp;title='.urlencode(utf8_strcut(get_text($view['wr_subject']),140));
?>
<ul>
<li><a href="<?=$sns_send?>&amp;sns=facebook" target="_blank"><img src="<?php echo G4_SNS_URL; ?>/icon/facebook.png" alt="이 글을 내 페이스북 계정으로 보내기"></a></li>
<li><a href="<?=$sns_send?>&amp;sns=twitter" target="_blank"><img src="<?php echo G4_SNS_URL; ?>/icon/twitter.png" alt="이 글을 내 트위터 계정으로 보내기"></a></li>
<li><a href="<?=$sns_send?>&amp;sns=me2day" target="_blank"><img src="<?php echo G4_SNS_URL; ?>/icon/me2day.png" alt="이 글을 내 미투데이 계정으로 보내기"></a></li>
<li><a href="<?=$sns_send?>&amp;sns=gplus" target="_blank"><img src="<?php echo G4_SNS_URL; ?>/icon/gplus.png" alt="이 글을 내 구글플러스 계정으로 보내기"></a></li>
</ul>
<?php
// 코멘트 입출력
include_once('./view_comment.php');

View File

@ -31,13 +31,13 @@ if (!$config['cf_sns_use']) return;
}
if ($facebook_user) {
echo '<input type="checkbox" name="facebook_checked" id="facebook_checked" '.($member['mb_facebook_checked']?'checked':'').' value="1">';
echo '<img src="'.G4_SNS_URL.'/icon/facebook_on.png" id="facebook_icon">';
echo '<input type="checkbox" name="facebook_checked" id="facebook_checked" '.(get_cookie('ck_facebook_checked')?'checked':'').' value="1">';
echo '<img src="'.G4_SNS_URL.'/icon/facebook.png" id="facebook_icon">';
} else {
$facebook_url = $facebook->getLoginUrl(array("redirect_uri"=>G4_SNS_URL."/facebook/callback.php", "scope"=>"publish_stream,read_stream,offline_access", "display"=>"popup"));
echo '<input type="checkbox" name="facebook_checked" id="facebook_checked" disabled value="1">';
echo '<a href="'.$facebook_url.'" id="facebook_url" onclick="return false;"><img src="'.G4_SNS_URL.'/icon/facebook_'.($facebook_user?'on':'off').'.png" id="facebook_icon"></a>';
echo '<a href="'.$facebook_url.'" id="facebook_url" onclick="return false;"><img src="'.G4_SNS_URL.'/icon/facebook'.($facebook_user?'':'_off').'.png" id="facebook_icon"></a>';
echo '<script>$(function(){ $("#facebook_url").click(function(){ window.open(this.href, "facebook_url", "width=600,height=250"); }); });</script>';
}
}
@ -80,15 +80,39 @@ if (!$config['cf_sns_use']) return;
}
if ($twitter_user) {
echo '<input type="checkbox" name="twitter_checked" id="twitter_checked" '.($member['mb_twitter_checked']?'checked':'').' value="1">';
echo '<img src="'.G4_SNS_URL.'/icon/twitter_on.png" id="twitter_icon">';
echo '<input type="checkbox" name="twitter_checked" id="twitter_checked" '.(get_cookie('ck_twitter_checked')?'checked':'').' value="1">';
echo '<img src="'.G4_SNS_URL.'/icon/twitter.png" id="twitter_icon">';
} else {
echo '<input type="checkbox" name="twitter_checked" id="twitter_checked" disabled value="1">';
echo '<a href="'.$twitter_url.'" id="twitter_url" onclick="return false;"><img src="'.G4_SNS_URL.'/icon/twitter_'.($twitter_user?'on':'off').'.png" id="twitter_icon"></a>';
echo '<a href="'.$twitter_url.'" id="twitter_url" onclick="return false;"><img src="'.G4_SNS_URL.'/icon/twitter'.($twitter_user?'':'_off').'.png" id="twitter_icon"></a>';
echo '<script>$(function(){ $("#twitter_url").click(function(){ window.open(this.href, "twitter_url", "width=600,height=250"); }); });</script>';
}
}
//============================================================================
//============================================================================
// 미투데이
//----------------------------------------------------------------------------
if ($config['cf_me2day_key']) {
$me2day_user = false;
if (empty($_SESSION['me2day']['user_id']) || empty($_SESSION['me2day']['user_key'])) {
$result = json_decode(file_get_contents("http://me2day.net/api/get_auth_url.json?akey=".$config['cf_me2day_key']));
$me2day_url = $result->url;
} else {
$me2day_user = true;
}
if ($me2day_user) {
echo '<input type="checkbox" name="me2day_checked" id="me2day_checked" '.(get_cookie('ck_me2day_checked')?'checked':'').' value="1">';
echo '<img src="'.G4_SNS_URL.'/icon/me2day.png" id="me2day_icon">';
} else {
echo '<input type="checkbox" name="me2day_checked" id="me2day_checked" disabled value="1">';
echo '<a href="'.$me2day_url.'" id="me2day_url" onclick="return false;"><img src="'.G4_SNS_URL.'/icon/me2day'.($me2day_user?'':'_off').'.png" id="me2day_icon"></a>';
echo '<script>$(function(){ $("#me2day_url").click(function(){ window.open(this.href, "me2day_url", "width=1000,height=800"); }); });</script>';
}
}
//============================================================================
?>
</div>
</td>