엑셀로 게시판 일괄 업로드를 활용하고있는데, 유튜브영상에 대한 데이터는 추출하지 못하고 있네요 ㅠ
본문
$write_table = "g5_write_{$bo_table}";
for ($i = 2; $i <= count($data->sheets[0]["cells"]); $i++) { //$i == 몇번째 라인부터 등록할건지
$total_count++;
if($_POST['ex_type'] == "2"){
$mb_id = $member['mb_id'];
$wr_name = $member['mb_nick'];
$wr_password = $member['mb_password'];
$wr_email = $member['mb_email'];
$wr_homepage = $member['mb_homepage'];
$wr_num = get_next_num($write_table);
$wr_reply = '';
$wr_content = addslashes($data->sheets[0]['cells'][$i][9]); //내용
$ca_name = addslashes($data->sheets[0]['cells'][$i][8]); //분류
$wr_subject = addslashes($data->sheets[0]['cells'][$i][1]); //제목
$wr_1 = addslashes($data->sheets[0]['cells'][$i][2]); //
$wr_2 = addslashes($data->sheets[0]['cells'][$i][3]); //
$wr_3 = addslashes($data->sheets[0]['cells'][$i][6]); //
$wr_4 = addslashes($data->sheets[0]['cells'][$i][4]); //
//$wr_5 = addslashes($data->sheets[0]['cells'][$i][]); //
//$wr_6 = addslashes($data->sheets[0]['cells'][$i][]); //
$wr_7 = addslashes($data->sheets[0]['cells'][$i][5]); //
$wr_8 = addslashes($data->sheets[0]['cells'][$i][7]); //
//$wr_9 = addslashes($data->sheets[0]['cells'][$i][]); //
$wr_10 = addslashes($data->sheets[0]['cells'][$i][10]); //영상링크
$wr_link1 = addslashes($data->sheets[0]['cells'][$i][11]); //다운로드 링크1
$wr_link2 = addslashes($data->sheets[0]['cells'][$i][12]); //다운로드 링크2
$wr_link3 = addslashes($data->sheets[0]['cells'][$i][13]); //다운로드 링크3
$wr_link4 = addslashes($data->sheets[0]['cells'][$i][14]); //다운로드 링크4
$sql = " update {$write_table}
where wr_num = '$wr_num',
wr_reply = '$wr_reply',
wr_comment = 0,
ca_name = '$ca_name',
wr_option = '$html,$secret,$mail',
wr_subject = '$wr_subject',
wr_content = '$wr_content',
wr_link1 = '$wr_link1',
wr_link2 = '$wr_link2',
wr_link1_hit = 0,
wr_link2_hit = 0,
wr_hit = 0,
wr_good = 0,
wr_nogood = 0,
mb_id = '$mb_id',
wr_password = '$wr_password',
wr_name = '$wr_name',
wr_email = '$wr_email',
wr_homepage = '$wr_homepage',
wr_datetime = '".G5_TIME_YMDHIS."',
wr_last = '".G5_TIME_YMDHIS."',
wr_ip = '{$_SERVER['REMOTE_ADDR']}',
wr_1 = '$wr_1',
wr_2 = '$wr_2',
wr_3 = '$wr_3',
wr_4 = '$wr_4',
wr_5 = '$wr_5',
wr_6 = '$wr_6',
wr_7 = '$wr_7',
wr_8 = '$wr_8',
wr_9 = '$wr_9',
wr_10 = '$wr_10'";
sql_query($sql);
}else{
$mb_id = $member['mb_id'];
$wr_name = $member['mb_nick'];
$wr_password = $member['mb_password'];
$wr_email = $member['mb_email'];
$wr_homepage = $member['mb_homepage'];
$wr_num = get_next_num($write_table);
$wr_reply = '';
$wr_content = addslashes($data->sheets[0]['cells'][$i][9]); //내용
$ca_name = addslashes($data->sheets[0]['cells'][$i][8]); //분류
$wr_subject = addslashes($data->sheets[0]['cells'][$i][1]); //제목
$wr_1 = addslashes($data->sheets[0]['cells'][$i][2]); //
$wr_2 = addslashes($data->sheets[0]['cells'][$i][3]); //
$wr_3 = addslashes($data->sheets[0]['cells'][$i][6]); //
$wr_4 = addslashes($data->sheets[0]['cells'][$i][4]); //
//$wr_5 = addslashes($data->sheets[0]['cells'][$i][]); //
//$wr_6 = addslashes($data->sheets[0]['cells'][$i][]); //
$wr_7 = addslashes($data->sheets[0]['cells'][$i][5]); //
$wr_8 = addslashes($data->sheets[0]['cells'][$i][7]); //
//$wr_9 = addslashes($data->sheets[0]['cells'][$i][]); //
$wr_10 = addslashes($data->sheets[0]['cells'][$i][10]); //영상링크
$wr_link1 = addslashes($data->sheets[0]['cells'][$i][11]); //다운로드 링크1
$wr_link2 = addslashes($data->sheets[0]['cells'][$i][12]); //다운로드 링크2
$wr_link3 = addslashes($data->sheets[0]['cells'][$i][13]); //다운로드 링크3
$wr_link4 = addslashes($data->sheets[0]['cells'][$i][14]); //다운로드 링크4
$sql = " insert into $write_table
set wr_num = '$wr_num',
wr_reply = '$wr_reply',
wr_comment = 0,
ca_name = '$ca_name',
wr_option = '$html,$secret,$mail',
wr_subject = '$wr_subject',
wr_content = '$wr_content',
wr_link1 = '$wr_link1',
wr_link2 = '$wr_link2',
wr_link1_hit = 0,
wr_link2_hit = 0,
wr_hit = 0,
wr_good = 0,
wr_nogood = 0,
mb_id = '$mb_id',
wr_password = '$wr_password',
wr_name = '$wr_name',
wr_email = '$wr_email',
wr_homepage = '$wr_homepage',
wr_datetime = '".G5_TIME_YMDHIS."',
wr_last = '".G5_TIME_YMDHIS."',
wr_ip = '{$_SERVER['REMOTE_ADDR']}',
wr_1 = '$wr_1',
wr_2 = '$wr_2',
wr_3 = '$wr_3',
wr_4 = '$wr_4',
wr_5 = '$wr_5',
wr_6 = '$wr_6',
wr_7 = '$wr_7',
wr_8 = '$wr_8',
wr_9 = '$wr_9',
wr_10 = '$wr_10'";
sql_query($sql);
$wr_id = sql_insert_id();
// 부모 아이디에 UPDATE
sql_query(" update $write_table set wr_parent = '$wr_id' where wr_id = '$wr_id' ");
// 새글 INSERT
sql_query(" insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '{$bo_table}', '{$wr_id}', '{$wr_id}', '".G5_TIME_YMDHIS."', '{$mb_id}' ) ");
// 게시글 1 증가
sql_query("update {$g5['board_table']} set bo_count_write = bo_count_write + 1 where bo_table = '{$bo_table}'");
}//type end
}//for end
alert("업로드 되었습니다",G5_BBS_URL."/board.php?bo_table=".$bo_table);
}
이렇게 엑셀등록하여 게시글을 등록할 수 있도록 구현은 하였는데, 자료도 잘 올라는 상태입니다.
그런데 게시판이 유튜브 영상에 대한 출처, 길이, 내용을 추출하여 보여지고 있는데,
엑셀로 등록하게되면 그에대한 정보가 불러오지 않아서요 ....
하나하나 글쓰기폼으로 진행하면 잘 추출이 됩니다. ㅠㅠ
글쓰기 페이지에서는 업데이트 스킨파일을 만들어 이렇게 사용중에 있습니다.
//$wr_7 = @implode("|", $_POST['wr_7']);
$wr_8 = @implode("|", $_POST['wr_8']);
$wr_3 = @implode("|", $_POST['wr_3']);
$wr_2 = @implode("|", $_POST['wr_2']);
$wr_4 = @implode("|", $_POST['wr_4']);
$url = "https://www.googleapis.com/youtube/v3/videos?key=API키&part=snippet,contentDetails,statistics&id=".$_POST['wr_10'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($ch);
curl_close($ch);
$result = json_decode($content,true);
$wr_5 = $result['items']['0']['snippet']['thumbnails']['medium']['url']; // 썸네일
$wr_6 = $result['items']['0']['snippet']['channelTitle']; // 출처
$wr_9 = str_replace("PT","",str_replace("M","분",str_replace("S","초",$result['items'][0]['contentDetails']['duration']))); // 시간
$wr_content = $result['items'][0]['snippet']['description']; // 내용
$sql = " update $g5[write_prefix]$bo_table set
wr_3 = '$wr_3',
wr_8 = '$wr_8',
wr_2 = '$wr_2',
wr_4 = '$wr_4',
wr_5 = '$wr_5',
wr_6 = '$wr_6',
wr_9 = '$wr_9',
wr_option = 'html2',
wr_content = '$wr_content'
where wr_id = '$wr_id' ";
sql_query($sql);
자문좀 구해보려 글을 올려봅니다.
!-->!-->
답변을 작성하시기 전에 로그인 해주세요.