묻고답하기
카카오톡 api가 바꼈네요 ㅠㅠ
2018.06.18 23:20
<?php
if(!(defined("__ZBXE__") || defined("__XE__"))) exit();
if(Context::getResponseMethod() == "XMLRPC" || Context::get('module') == "admin") return;
if($called_position != "before_display_content") return;
if($called_position == 'before_display_content' && Context::getResponseMethod() == 'HTML') {
$pos_regx = "!<\!--AfterDocument\(([0-9]+),([0-9]+),([0-9]+)\)-->!is";
$document_srl = intval(Context::get('document_srl'));
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument(Context::get('document_srl'), false, false);
if (!$oDocument) return;
if($addon_info->talk_use!='N' || $addon_info->story_use!='N') {
$appname = $addon_info->appname;
if (!$appname) $appname = $oDocument->getTitleText();
$button_align = $addon_info->button_align;
$button_width = $addon_info->button_width;
if (!$button_width) $button_width = '35';
$talk_thumbnail_width = $addon_info->talk_thumbnail_width;
if(!$talk_thumbnail_width) $talk_thumbnail_width='300';
$talk_thumbnail_height = $addon_info->talk_thumbnail_height;
if(!$talk_thumbnail_height) $talk_thumbnail_height='200';
$kakao_script="
<script src='https://developers.kakao.com/sdk/js/kakao.min.js'></script>
<script>
Kakao.init('".$addon_info->javascript_key."'); // 사용할 앱의 Javascript 키를 설정해 주세요.
";
$page_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REDIRECT_URL'];
$before = '<div style="text-align: '.$button_align.';"><img src="/addons/sejin7940_kakao_link/img/title-sns.png" style="border:0;" />';
if($addon_info->use_facebook == 'Y')
$before .= '<a href="javascript:;" onclick="window.open(\'http://www.facebook.com/sharer/sharer.php?u='.urlencode($page_url).'&t='.urlencode($GLOBALS[oContext]->context->item_info->item_name).'\', \'facebook\', \'width=1000, height=640, menubar=no, status=no\')"><img src="/addons/sejin7940_kakao_link/img/use_facebook.png" width="'.$button_width.'" /></a> ';
if($addon_info->use_twitter == 'Y')
$before .= '<a href="javascript:;" onclick="window.open(\'http://twitter.com/share?url='.urlencode($page_url).'&text='.urlencode($GLOBALS[oContext]->context->item_info->item_name).'\', \'facebook\', \'width=500, height=500, menubar=no, status=no\')"><img src="/addons/sejin7940_kakao_link/img/use_twitter.png" width="'.$button_width.'" /></a> ';
// 카카오링크 ver 3.5 ( ver 2.0 서비스 종료. 3.5 정식 지원)
if($addon_info->talk_use!='N') {
$kakao_script.="
var filter = 'win16|win32|win64|mac';
var is_pc = false;
if(navigator.platform)
{
if(filter.indexOf(navigator.platform.toLowerCase()) >= 0)
{
is_pc = true;
}
}
if (is_pc == false)
{
Kakao.Link.createTalkLinkButton({
container: '#kakao-link-btn',
label: '".$oDocument->getTitleText()."',
";
if($oDocument->getThumbnail()) $kakao_script.=" image: { src: '".$oDocument->getThumbnail($talk_thumbnail_width,$talk_thumbnail_height)."', width: '".$talk_thumbnail_width."', height: '".$talk_thumbnail_height."' },";
$kakao_script.="
webButton: { text: '".$appname."', url: '".$oDocument->getPermanentUrl()."' }
});
}
";
$before .= '<a id="kakao-link-btn" class="kakao-mobile kakao-link-btn" href="javascript:;" ><img src="/addons/sejin7940_kakao_link/img/kakaotalkicon_150150.png" width="'.$button_width.'" /></a>';
}
// 카카오스토리 ver 3.5 (아직 정식 API 개발 미완 상태. ver 2.0 으로 작동 - 자료실에 있는 카카오스토리 애드온을 사용할것 )
if($addon_info->story_use!='N') {
$kakao_script.="
jQuery(document).ready(function() {
jQuery('.kakao-story-btn').click(function() {
var filter = 'win16|win32|win64|mac';
if(navigator.platform)
{
if(filter.indexOf(navigator.platform.toLowerCase()) >= 0)
{
alert('모바일에서만 이용하실 수 있습니다');
return false;
}
}
Kakao.Auth.login({
success: function() {
// 로그인 성공시, API를 호출합니다.
Kakao.API.request( {
url : '/v1/api/story/linkinfo',
data : {
url : '".$oDocument->getPermanentUrl()."'
}
}).then(function(res) {
// 이전 API 호출이 성공한 경우 다음 API를 호출합니다.
res.host='"."http://".$_SERVER['HTTP_HOST']."';
res.title='".$oDocument->getTitleText()."';
res.description='".preg_replace("/[\n\r]/", "", $oDocument->getSummary(100))."';
return Kakao.API.request( {
url : '/v1/api/story/post/link',
data : {
link_info : res
}
});
}).then(function(res) {
return Kakao.API.request( {
url : '/v1/api/story/mystory',
data : { id : res.id }
});
}).then(function(res) {
// document.getElementById('post-result').innerHTML = JSON.stringify(res);
return Kakao.API.request( {
url : '/v1/api/story/linkinfo',
data : { id : res.id }
});
}, function (err) {
alert(JSON.stringify(err));
});
},
fail: function(err) {
alert(JSON.stringify(err))
}
});
});
});
";
if($addon_info->talk_use!='N') $before .= " ";
$before .= '<a id="kakao-story-btn" class="kakao-mobile kakao-story-btn" href="javascript:;"><img src="/addons/sejin7940_kakao_link/img/kakaostroyicon_150150.png" width="'.$button_width.'" /></a>';
}
$before .= '</div>';
$kakao_script.="
</script>";
카카오버전v2로 변경이 되었던데..여기서 어떻게 바꿔줘야 할까요?ㅠㅠ
기존껀 사용이 안되네요