/**
* 다음뷰위젯 출력.. 1은 큰것 2는 중간것 3은 버튼
*/
function showDaum($ttty) {
$nid =getNid();
$box = array(
1=>'',
2=>'',
3=>''
);
if($nid != -1) echo $box[$ttty];
}
/**
* 다음뷰에 포스트가 송고 되어 있는지 체크
*/
function getNid() {
global $ID;
$ret = -1;
$xml = getXML("api.v.daum.net","/open/news_info.xml?permalink=".DOKU_URL.str_ireplace(':','/',$ID));
if(is_object($xml)) {
if($xml->head->code ===== "200") $ret = $xml->entity->news->id;
}
return $ret;
}
/**
* xml 가져오기...
*/
function getXML($url, $uri) {
if(!($fp=fsockopen($url, 80, $errno, $errstr, 5 )))
fprintf( stderr, $errstr );
$out = "GET $uri HTTP/1.1\r\n";
$out .= "Host: api.v.daum.net\r\n";
$out .= "Connection:Close\r\n\r\n";
fputs( $fp, $out );
while( $data = fgets($fp) ){
if( !trim($data) )
break; }
$data = stream_get_contents($fp);
return simplexml_load_string($data);
}